redux-logic icon indicating copy to clipboard operation
redux-logic copied to clipboard

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

Open jcheroske opened this issue 8 years ago • 4 comments

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 avatar Jul 14 '17 06:07 jcheroske

Ping...

jcheroske avatar Jul 19 '17 21:07 jcheroske

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?

jeffbski avatar Jul 25 '17 13:07 jeffbski

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

jcheroske avatar Sep 23 '17 04:09 jcheroske

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.

jeffbski avatar Sep 23 '17 18:09 jeffbski