npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

herculex

v0.2.16-alpha.3

Published

Simple, predictable, developer friendly state management for alipay mini-program

Downloads

26

Readme

herculeX

Simple, predictable, lightweight, high performance, developer friendly state management for alipay mini-program

setData (1).png

Feature

  • [x] Component, Page, global wrapper
  • [x] vuex-like apis and concept: actions, mutations, getters, plugins
  • [x] strengthen mutation, getters: add immutable helper, global power to getters.and improve mutation usecase, add some common innerMutation
  • [x] plugins support, add logger as inner plugin
  • [x] cross page communication: message channel, auto router dispatcher(manage router ), get ready-only State by namespace
  • [x] cross components communication: support centralized ref management
  • [x] connect: connect Page to Component, add mapStateToProps, mapGettersToProps, use more developer friendly way.
  • [x] mapHelpers: connect actions and mutations to Page, Componnet methods
  • [x] global store support: manage all store, component instance and global state, global message bus ,event bus
  • [x] event bus support
  • [x] router: improve router usecase, auto router dispatcher, add resume lifecycle
  • [x] utils: immutable heplers, common functional tools, urlParser, promiseWrapper...
  • [x] use immer and immutable helper to promise immutable
  • [x] magic memoization: add special memoization feature to mapHelpersToProps

Installation

  • Installation: npm install herculex --save.
  • basic usage:
    • index.js
    import store from './store';
    const app = getApp();
    Page(store.register({
      mapActionsToMethod: ['getUserInfo'],
      mapMutationsToMethod: ['helperWay'],
      onLoad() {
       const message = this.$message.pop('card-home');
       // get message from last page as you like
      },
      onReady() {
        const componentInstance = this.$getRef('card-input');
        // get component ref, then get data when you need ,specially in form condition
      },
      onResume(ctx) {
       // get ctx here, 
      },
      ...
      onTap() {
      }
    })
    • store.js
     export default new Store({
     connectGlobal: true,
     state: {
         userInfo: {},
         bannerList: [],
         UI,
      },
     getters: {
      // functional promgraming, add some helpers
      cardCount: (state, getters, global) => global.getIn(['entity', 'cardList', 'length'], 0),
      avatar: state => state.getIn(['userInfo', 'iconUrl'], ASSETS.DEFAULT_AVATAR),
      nickName: state => state.getIn(['userInfo', 'nick']),
      cardList: (state, getters, global) => global.getIn(['entity', 'cardList'], []).map(mapCardItemToData),
     },
     mutations: {
       mutableWay(state, payload) {
       // use immer promise immutable
        state.a = payload.a
       },
       helperWay(state, payload) {
         // use inner helper: setIn, deleteIn, update
        return state.setIn(['userInfo', 'name'], payload.name)
       }
     },
     plugins: [ 'logger' ], // inner plugin logger
     actions: {
       async getUserInfo({ commit, state, dispatch, global, getters, }, payload) {
         // get router and context in global store, all state are binded immutable helper
         const routerCtx = global.getIn(['router', 'currentRouter']);
         const avatar = getters.getIn('avatar');
         const userInfo = await cardListService.getUserInfo();
         commit('getUserInfo', { userInfo });
       },
     },
    });
    • index.axml
    <view a:if="{{!!$global.entity.cardList}}">
      {{userInfo.name}}
       <navigator a:if="{{$getters.cardCount > 0}}" class="link" url="/pages/card-create/index">
          <button type="primary">{{UI.TEST}}</button>
       </navigator>
    </view>

Examples

  • appx (alipay mini program)
    • quick start
      • Counter : show basic usage as commit & dispatch
      • TODOS: show how components and modules work

Turtoral

TODO

  • [ ] add pageBeforeRender Action to do something before instance created
  • [ ] add travis ci
  • [ ] add middleware support, take over api middleware
  • [ ] doc & gitbook,github.io
  • [ ] examples & boilerplate
  • [ ] cli for static code check, and generate snipets
  • [ ] ide plugin
  • [ ] model based api middleware
  • [ ] test-utils & mock helper
  • [ ] dev-tools for ide & standalone
  • [ ] modules (need deeply design)
  • [ ] error catcher plugin
  • [ ] refactory and tests, separate appx data setter as independent repo