Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance the subscribe api #86

Open
4 tasks done
ArrayZoneYour opened this issue Mar 26, 2019 · 0 comments
Open
4 tasks done

Enhance the subscribe api #86

ArrayZoneYour opened this issue Mar 26, 2019 · 0 comments
Assignees
Labels
discuss ✨Feature Request New feature or request

Comments

@ArrayZoneYour
Copy link
Contributor

ArrayZoneYour commented Mar 26, 2019

I have a:

  1. Idea:

    • What problem would it solve for you? 🐛
      Developer can subscribe the state changes.
      v2.x api

      // subscribe actions
      // (storeName, actionList, callback) => void
      subscribe('Counter', ['increment'], () => (count += 1))
      // subscribe properties changes
      // (storeName, mapStateFunction, callback) => void
      subscribe('Counter', state => state.count, () => alert('counter count change!'))

      v3.x api

      const store = Store({
         // ...
        actions: {
          updateA: (s, payload) => { ... },
          updateC: (s, payload) => { ... },
          updateD: (s, payload) => { ... }
        }
      })
      // subscribe actions
      store.subscribe(['updateA'], () => (count += 1))
      // subscribe properties changes
      store.subscribe(state => state.A, () => alert('A change!'))
    • Do you think others will benefit from this change as well and it should in core package? 💡 Yes

    • Are you willing to (attempt) a PR yourself? ⚔
      Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss ✨Feature Request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants