1.0.3 • Published 6 years ago

moy-redux v1.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

moy-redux

haven't you heard redux?

it‘s the same principle as that.

Understand the concepts

  • IO -> a variable that can changed anytime and anywhere(effect)
  • Task -> an asynchronous task that we used in functional programming(like promise, but actually not the same)
  • store -> like redux store
  • state -> current store state
  • dispatch -> like redux, dispatch an applyer
  • applyer -> an applyer is a Map that just like applyerName, applyerFunction. when dispatch an applyer, they can get the applyerName and execute it's applyerFunction(Note: applyerFunction must return a Task)
  • subscription -> listener for state changed that it can execute automaticly
  • subscribe -> add listener for store(Note: listener just a function, you can use compose or parallel to add more than one function)

How it works

  1. you should create a store(with rfStore Function), right?
  2. when you did step 1, you can get an object that contains state(IO)、dispatch、subscribe and rfStore. what does this properties do, you may got it as mentioned above except rfStore.the rfStore Function is designed for this case: you should clearly change the store's state and applyers to a new state and new applyers such as route changed
  3. you can dispatch an applyer with payload
  4. the store get the action and find the apllyer in it's applyers. we use Maybe monad for this case if your applyName doesn't exist
  5. if can't find the applyer, nothing happened(will not take the following steps). if exist, we use ap function to execute this function
  6. store get the applyerFunction return values Task
  7. use chain to remove Maybe monad and fork Task and changed store's state to a new state ({...state, ...changes}) with this changes
  8. when state changed, the subscription will called(if exist)
  9. waitting for a new dispatch
  10. Note: when you use rfStore to set a new state and new applyers, the subscription will be called(store'sstate changed right?)

License

MIT

Copyright (jp) 2018-present murakami

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

0.8.9

6 years ago

0.8.7

6 years ago

0.8.6

6 years ago

0.8.5

6 years ago

0.8.3

6 years ago