Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

enhancement: store.subscribe(listener, filter)#2814

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@warren-bank
Copy link

new (optional) input parameter:filter

  • its purpose is to conditionally filter whenlistener is called
  • when its value is:
    • undefined:
      • listener is called as normal
    • function:
      • input: (oldState, newState)
      • output: boolean
        • when truthy,listener is not informed of this state change
    • boolean && true:
      • listener is not informed whennewState
        is equal (by reference) tooldState

new (optional) input parameter: `filter`* its purpose is to conditionally filter when `listener` is called* when its value is:  * undefined:    * `listener` is called as normal  * `function`:    * input: (oldState, newState)    * output: boolean      * when truthy, `listener` is not informed of this state change  * `boolean` && true:    * `listener` is not informed when `newState`      is equal (by reference) to `oldState`
@warren-bank
Copy link
Author

warren-bank commentedJan 28, 2018
edited
Loading

Hi.

I was just thinking..

  • maybe the namefilter wasn't the absolute best choice?
    • normally, a filter function returns true to include and false to exclude..
      • whereas this is the other way around
    • wouldignore orskip be preferable?
    • of course, this is strictly internal..
      • users passing a function intosubscribe can call it anything they like..
      • or make it anonymous (for that matter)

Do you have any opinion?

npm installnode_modules/.bin/prettier "src/createStore.js" >"src/createStore.js"
@markerikson
Copy link
Contributor

markerikson commentedJan 29, 2018
edited
Loading

This is very similar to the frequently-requested idea of having state and/or action passed to listeners, and we have no plans to implement this. If you'd like to do it yourself, you can implement it as a store enhancer.

For more info, see the FAQ entry onwhy state and action are not passed to subscribers, and the many prior discussions listed in issue#580 .

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@warren-bank@markerikson

[8]ページ先頭

©2009-2025 Movatter.jp