comparison to (re)actors ??
See original GitHub issueI’m trying to decide whether my project should use sagas or (re)actors (or both), and besides the documentation for this project I have also read:
- http://jamesknelson.com/join-the-dark-side-of-the-flux-responding-to-actions-with-actors/
- https://medium.com/@mtiller/encapsulating-application-logic-with-reactors-392635763e7
Actors are a sequence of functions which are called each time your store’s state changes, with one important exception: they aren’t called in response to actions dispatched from other actors.
This isn’t really a property of actors, but of the suggested approach of hooking them up to the store:
// An array of actor functions taking a `state` object and `dispatch` function
var actors = [ ... ]
var acting = false
store.subscribe(function() {
// Ensure that any action dispatched by actors do not result in a new
// actor run, allowing actors to dispatch with impunity.
if (!acting) {
acting = true
actors.forEach(function() {
actor(store.getState(), store.dispatch)
})
acting = false
}
})
They even go so far as to implement the connection between React and Redux as the final actor in the sequence, so that React render calls for intermediate synchronous states are avoided.
It seems as though both saga and actor approaches offer comparable side-effect management.
- is the actor approach better approach for synchronous side-effects in terms of React efficiency?
- is the saga approach better for asynchronous side-effects in terms of declaration and testing?
- is it likely that a project would ever benefit from using both? or do most use cases fit cleanly into either one or the other approach?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top Results From Across the Web
When Actors Can Benefit From Comparisons
There are times when actors can benefit from making comparisons. Here's how to make comparison work for you and how to know when...
Read more >Comparison....#ActorProblems The problem when we ...
The problem when we compare is that we “look at someone's title - but we don't look at their text.” We loooove looking...
Read more >Comparison of reactors | 20 | Chemical Reaction Engineering
The choice of the reactor is very important and should be carried out on technical basis. There are three main criteria to distinguish...
Read more >Comparison of reactors | Request PDF
Structured reactors in principle are a better option because they allow more degrees of freedom. Nevertheless, structured reactors are not generally used in ......
Read more >Voice Compare: Green Lantern - Tomar-Re
Comparison of the voice actors who have been the voice of Tomar-Re with sound clips and images. Number of Comparisons: 6. Franchise: Green ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@slorber From the 1st link I think the author gives a different meaning to actors than the one commonly known in the Actor model.
@jokeyrhyme Actors in the Actor model communicates by sending messages to each other while in the above link the author talks about reacting to state changes. In the mentioned article, actors are functions invoked on each state change, can dispatch actions and forms a kind of a pipeline where each actor can see the results of actions dispatched by previous actors on the chain.
I can see 2 principal concerns from my rapid lecture
The 2nd concern seems more technical than conceptual and IMO can be handled by different means (like using redux-batched-actions).
The 1st concern joins somewhat the Saga purpose, as Sagas can also translate user events into business events that maybe handled by other Sagas. And those Sagas can in turn generate other events to be used by other Sagas.
I don’t see why the author chose to deliberately ignore actions and just examines state changes in order to infer the next action or effect. It means the developer will likely store more control state in the store in order to give re-actors enough information to decide what to do.
Thanks everyone, that’s given me a lot to think about. 😃