calmm-js / documentation

How does it all fit together?
184 stars 11 forks source link

Side effects within calmm-js #2

Open aksonov opened 8 years ago

aksonov commented 8 years ago

I've asked this question within Gitter, maybe it will be useful to add more documentation about it:

Hi! I'm new in FRP world and just found your library. I'm building chat-based app and trying to make my xmpp work in FRP fashion - trying to migrate from redux where i have already too much boilerplate. In redux i have action creator that call xmpp connect function and then change state within xmpp reducer. Now i want to implement the same using Calmm. I've read https://github.com/calmm-js/documentation/blob/master/redux-vs-calmm.md but it seems not have "howto" about doing things "right" in Calmm, but just comparison. I've checked TodoMVC example, but it doesn't look very clear.

In other words how to do properly side effects using Calmm?

aksonov commented 8 years ago

Sorry, i still doesn't see what is best place to put side effects and how to pass it to React - i didn't found any example with side effect, could you provide some examples with fetch or other side effect?

polytypic commented 8 years ago

FYI, I'm currently a little bit too busy at work to write examples. I'll try to find some time to write a simple example ASAP, but don't hold your breath. :)

aksonov commented 8 years ago

ok :) Alteast could I ask some questions about side effects here? For example i need to load user profile after login. Could Profile data be an atom? I need to persist it (including sessionID) to local storage (to avoid login each app run), but also this data should be updated properly after each user login.

So from one side it should be atom (so user may modify it), but from other side it should be updated when user does re-login (i.e. "computed" value)