reductive-dev-tools
reductive-dev-tools copied to clipboard
Extensible variant name becomes "update" for all actions inside the extension
I have been following the examples from reductive
, in particular those with thunk
middleware, and noticed that all actions are displayed with the name update
in the dev-tools extension if using a middleware. Looks like this:
Interesting that the actual name of the variant is hidden inside of the action structure (in the example above it is CounterAction
), so I am guessing it gets wrapped because of the middleware and gets some default name which is update
. Does anyone know why this is happening?
I really like this library and think it would really cool to make it work with the setup reductive
+ thunk
+ reductive-dev-tools
to show the actual action dispatched (if it is of course possible). I am ready to help fixing the issue, but would need some help.
Thanks for the great work on the library and appreciate any help here :)
may I ask you to post an example that I can reproduce?
In the following case (with -bs-g
) flag, debug metadata Symbol(BsVariant): 'ReduxThunk.Thunk'
should normally be attached to ReduxThunk.Thunk(incrementAsync)
object, so reductive-dev-tools
will turn into the value of type
key which will then be used as an action name by redux-devtools-extension
dispatch(ReduxThunk.Thunk(incrementAsync))
update
is a default redux-devtools-extension
action name when there is no type
key in an action passed to extension.
Based on your rawValue
, it looks like the extension doesn't really receive a variant with debug metadata (a reason variant with constructor which is a js-array on runtime with the BsVariant symbol set), possible issue on reductive-dev-tools
side maybe
I was trying to create a codesandbox
reproducible example, but got errors while trying to include reductive-dev-tools
as a dependency.
Would you be willing to look into my repo where the issue occurs? Greatly appreciate any help!
Went through your repo.
Partially defined(if my terminology is right) variant (Thunk) has different runtime representation and doesn’t contain debug metadata symbol attached to it.
When I redefined Thunk as a fully defined variant, redux-devtools-extension would correctly display the names.
personally I was unaware of this partial variant definition before so I haven’t tested it before now.
There are two approaches I see reasonable here:
- Change Thunk to polymorphic variants.
- Customly annotate the actions dispatched (via additional annotation APIs provided by reductive-dev-tools)
I think it is called extensible variant type
, looked it up in the ocaml docs.
Would you mind sharing your implementation with redefining Thunk
variant? I am not very good with reasonml
, or ocaml
for that matter, so it is quite a struggle for me with such advanced concepts.
Could you also point me to where in the docs of reductive-dev-tools
it says about custom annotation of actions? Is it section Additional tagging and point 1 Labeling variants with constructors
?
Thanks for your help!
@MargaretKrutikova: Please reference https://github.com/MargaretKrutikova/reason-react-reductive-example/pull/1 with polymorphic variant used.
Thanks a lot for introducing extensible variant type
. In general circumstances it should be preferred to polymorphic, but until we figure out how to support them directly, polymorphic variants is the way to go for the structure like yours.
Is it section Additional tagging and point 1 Labeling variants with constructors?
Yes, pardon for confusion, additional-tagging allows to 'tag' objects in the same way how bucklescript does with -bs-g
flag enabled.
Thanks a lot for the PR and the explanations! I am still going through the code trying to figure out how everything hangs together :)
Is it reasonable to rename this issue since now we have figured out that the reason why action names aren't displayed correctly is not because of middleware but because of using extensible variant types for actions?
Yeah, good point, will keep this one open to track the progress on this