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

multi: Add Proposal Loader + Store Listeners #2755

Merged
merged 4 commits into from
Apr 27, 2022

Conversation

victorgcramos
Copy link
Member

This PR adds loading placeholders for loading proposals. Fixes #2748 (comment)

Screen Shot 2022-04-26 at 8 38 37 PM

It also introduces the new useStoreEffect hook, which uses the also implemented addStoreEffect listener to our Store.

Usage

You can use the addStoreEffect outside the React scope, and trigger a side effect when some action is dispatched. In the following example, we will add a listener, using the regarded method, to log a "Hello" message on the console after api is fetched:

addStoreEffect(() => {
  console.log("Hello!");
}, [api.fetch.fulfilled]);

Easy, huh?

If you're using it on some react component, and don't want it to be triggered on every render, you can use the useStoreEffect hook. In the following example, we will fetch records and ticketvote policies after api is fetched:

 useStoreEffect(() => {
    dispatch(ticketvotePolicy.fetch());
    dispatch(recordsPolicy.fetch());
  }, [api.fetch.fulfilled]);

Copy link
Member

@tiagoalvesdulce tiagoalvesdulce left a comment

Choose a reason for hiding this comment

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

LGTM

@tiagoalvesdulce tiagoalvesdulce merged commit d9dfb5d into decred:master Apr 27, 2022
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.

2 participants