Skip to content
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

Optional custom 'passToStore' code #58

Merged
merged 2 commits into from
Jun 27, 2018
Merged

Optional custom 'passToStore' code #58

merged 2 commits into from
Jun 27, 2018

Conversation

joshuamorris3
Copy link

Via the passToStoreHandler configuration option, you can provide a replacement or additional logic for the passToStore code in src/Observer.js.

The function you provide will be passed the following arguments:

  1. event name
  2. event
  3. original/default handler code function function (eventName, event). This allows you to optionally do some basic preprocessing before handing the event over to the original handler.

The original passToStore code is used if no passToStoreHandler is configured.

I've added new documentation describing this in more detail in README.md.

The one addition I'm not sure about is giving the custom passToStoreHandler function the this of the src/Observer.js by passing it in as an argument, or doing a .bind(this). Let me know if you think is something that should be added.

@intech
Copy link

intech commented Jun 27, 2018

+1

@weglov weglov merged commit a31cb5e into nathantsoi:master Jun 27, 2018
@weglov
Copy link
Collaborator

weglov commented Jun 27, 2018

Great feature, tnx @joshuamorris3

@intech
Copy link

intech commented Jun 27, 2018

@weglov are you publishing to npm this update?

@weglov
Copy link
Collaborator

weglov commented Jun 27, 2018

@intech a new version (2.0.8) was published

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

Successfully merging this pull request may close these issues.

3 participants