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

Add support for trigger[] in store.on #328

Merged
merged 8 commits into from Apr 23, 2020
Merged

Add support for trigger[] in store.on #328

merged 8 commits into from Apr 23, 2020

Conversation

sergeysova
Copy link
Sponsor Member

@sergeysova sergeysova commented Apr 23, 2020

import {createEvent, createStore} from 'effector'

const store = createStore(0)
const changedA = createEvent()
const changedB = createEvent()

store.on([changedA, changedB], (state, params) => state + params)

store.watch(value => {
  console.log('updated', value)
})

changedA(2)
// => updated 2

changedB(2)
// => updated 4

store.off(changedB)

@sergeysova sergeysova requested a review from zerobias Apr 23, 2020
@vercel vercel bot requested a deployment to Preview Apr 23, 2020 Abandoned
@vercel vercel bot requested a deployment to Preview Apr 23, 2020 Abandoned
Copy link
Member

@zerobias zerobias left a comment

Well done! It's always nice to see such a thorough study 👍

if (!Array.isArray(events)) {
onEvent(events, fn)
} else {
for (const event of events) {
Copy link
Member

@zerobias zerobias Apr 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! I didn’t even think about it that way

@zerobias zerobias merged commit 00fa87a into master Apr 23, 2020
1 of 3 checks passed
@delete-merged-branch delete-merged-branch bot deleted the feat/on-array branch Apr 23, 2020
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.

None yet

2 participants