-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to make dispatch
fired after decorated method is fired
#157
Comments
Or would it be better to add a |
Yes, good insight here. I think conceptually it makes sense that the tracking event is fired before the decorated function since syntactically that's how it appears: The Codesandbox Example linked to in the main README actually has an example of this (although it's not using redux). I'm sort of not inclined to adjust this API since I'd be concerned about the added complexity that would introduce, although happy to explore it further with you and see if there's a clean way to approach it. However, with the current API there are some options:
Curious to get your thoughts! |
@tizmagik Thanks for replying. Yeah i think if tracking is always gonna happen before dispatch then doing something like
cause that means people need to add separate piece of code in order to instrument tracking for every project. Like I copied and pasted earlier, the way i did it is expose that single decorator called Or Is it possible to make
and
at the same time? |
So the function signature @track((props) => ({ name: props.name || 'Foo' }), { dispatch, dispatchOnMount, process, forwardRef })
class Foo extends Component {
@track((props, state) => ({
action: state.following ? "unfollow clicked" : "follow clicked"
// note that "name" comes from the class-level decorator and is not needed here
}))
follow = () => {
// ... follow logic
}
} |
oh, ic. I think it actually should work with my setup. I will get back to u once i verified. Thanks for the example! |
hmmm just did some initial experiments on this.
seems that |
hmmm, i have one more question, I created a small react native project to try out advance feature of react-tracking. I notice once i add the following commit (i.e the latest commit in that repo) to |
If I had to guess, it's probably because the |
First of all really appreciate the effort on making this library and it saves me a lot of time to implement my own version.
The way I use react-tracking is like the following:
i also attach a bunch of metadata from redux store to the
optons.dispatch
. The problem i'm seeing is that let's say if we have a redux state calledcount
that's going to add 1 everytimeincrement
is fired. react-tracking will always attach the oldcount
as part of metadata instead ofcount + 1
after increment is fired. I'm assuming this is because react-tracking dispatches first before it actually fires the decorated function? So curious is there anyway around? Thanks and looking forward to any help here!The text was updated successfully, but these errors were encountered: