Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Pass Context to enhancers #101

Open
brendean opened this issue Apr 6, 2018 · 1 comment
Open

Pass Context to enhancers #101

brendean opened this issue Apr 6, 2018 · 1 comment

Comments

@brendean
Copy link

brendean commented Apr 6, 2018

Redux store enhancers dont have a way to access Context.

Type of issue

Feature request

Description

I created a plugin to allow cookie manipulation on the browser and server and would like to be able to access that plugin in a redux middleware. The use case is to set a cookie when a certain action is fired. Unless I'm missing something I would need to have access to the Context when creating that middleware (in order to get the cookie plugin via dep/token).

Current behavior

Currently enhancers (besides ctxEnhancer) are not passed ctx, code here:

const enhancers = [enhancer, ctxEnhancer(ctx), devTool].filter(

Expected behavior

Enhancers are changed to be returned from a function that is passed Context.

@AlexMSmithCA
Copy link
Member

Thanks @brendean!

You can access the Context via the store.ctx property that should be accessible by all enhancers. This is documented here.

For an example of usage, check out fusion-plugin-redux-action-emitter-enhancer.

Is this sufficient for your use case?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants