GithubHelp home page GithubHelp logo

Comments (4)

jtcrowson avatar jtcrowson commented on June 5, 2024

Hey @SilverTab!

One of my primary goals of the library is to make redux performant (hence the ReCombine tagline), so thank you for opening an issue. I think I have the answer you are looking for.

Approaches for Register an Effect

  1. In the Store constructor, as you mentioned (global/permanent Effects)
  2. Using the register instance method (local/temporary Effects)

Approach for you

Looks like you may consider option 2, which allows registering/deregistering Effects as you need them. You will define your API-based Effect the same way, but register with register instead of the Store constructor.

Documentation

Take a look at the documentation for register which includes further details on how to maintain the Effect, and an example.

Performance Impacts

Using the register method would lead to an obvious performance increase, since every dispatched action will not be processed by every Effect, and memory will not be allocated permanently for those Effects.

from recombine.

SilverTab avatar SilverTab commented on June 5, 2024

Ohhh I see, for some reason I thought that the register method was only for Effect that had dispatch set to false.
So if I understand what you're saying correctly, Effects that have the potential of affecting multiple parts of the app should probably be global/permanent ones (and registered using the Store constructor), but more local ones (e.g. loading some data from an API and display it in a View, where only that specific View cares about it) should be considered "local/temporary", and be registered using the register instance method, and will live only as long as the scope of the object that contains them? (model, view model or otherwise)?

from recombine.

jtcrowson avatar jtcrowson commented on June 5, 2024

You're 100% correct!

I'll try to clarify that part of the Effect Guide.

Feel free to close the issue, and give the repo a star!

from recombine.

SilverTab avatar SilverTab commented on June 5, 2024

You got it! :) Thanks for the clarifications!

from recombine.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.