question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

comparison to (re)actors ??

See original GitHub issue

I’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:

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:closed
  • Created 8 years ago
  • Reactions:3
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
yelouaficommented, Feb 22, 2016

@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

  1. ability to dispatch actions in reactions to other actions
  2. amelioration of performance rendering by not rendering on each state change

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.

0reactions
jokeyrhymecommented, Feb 22, 2016

Thanks everyone, that’s given me a lot to think about. 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found