jeffbski / redux-logic

Redux middleware for organizing all your business logic. Intercept actions and perform async processing.
MIT License
1.81k stars 107 forks source link

Is it possible to remove a single logic and not reset other logics' state? #67

Open jcheroske opened 7 years ago

jcheroske commented 7 years ago

I'm wanting the ability to remove a single logic in the most non-disruptive way possible. I saw replaceLogic, but that seems a bit heavy-handed.

jcheroske commented 7 years ago

Ping...

jeffbski commented 7 years ago

Yeah, since these are built-up as a chain, it is easy to add to the end or replace all, but not as easy to pull out a single one. Could I ask why you want to remove a single logic?

jcheroske commented 7 years ago

Very late reply... I'm exploring fractal redux components. Using libs like redux-subspace, which is going to feature dynamic reducer injection soon. It already has support for adding/removing sagas at runtime. I want to use this lib with it. Do you think it would be possible to add a method like:

import {createLogic, injectLogic} from 'redux-logic'

const logic = createLogic({...})
const remove = injectLogic(logic) // logic is now installed

// later on
remove() // logic is now gone
jeffbski commented 7 years ago

Sounds interesting, I'll learn more about redux-subspace.

I guess there could be a couple ways of possibly approaching this.

I could create a fn that would do the proper replaceLogic or I could possibly create a way to flip a flag to bypass this logic after this fn was called and toggling it again if re-injected.

I'll think about the best way to approach this desired use case.