Skip to content
This repository was archived by the owner on Jan 10, 2018. It is now read-only.
This repository was archived by the owner on Jan 10, 2018. It is now read-only.

Get the current value from store instantly #296

@peterbakonyi05

Description

@peterbakonyi05

Hi,

Some cases it would be useful to get the current value from the store instantly. Imagine that you react to a button click, and in order to dispatch an action you need some value from the store.

Currently you need to do this:

onLoginClick(loginData) {
    this.store.select(this.selector.getCountry())
        .take(1)
        .subscribe(country => {
            this.store.dispatch(this.action.login({
                loginData,
                country 
            }));
        });
}

With a get method it could be done like this:

onLoginClick(loginData) {
    this.store.dispatch(this.action.login({
        loginData,
        country: this.store.get(this.selector.getCountry())
    }));
}

The performance would be even better, because just to get the current value, you don't need to create a new Subscription. Do you think it makes sense to introduce a method like that on the Store?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions