Skip to content

Is it possible to get action and state in store.subscribe? #580

Closed
@antonmedv

Description

@antonmedv

I want to update my view in listener:

store.subscribe(() => {
    updateView(store.getState()); // Some DOM api calls.
});

But if it possible to get last action what triggered state change, i can do some think like this:

store.subscribe(() => {
    switch (action.type) {
        case UPDATE_TITLE:
            updateTitle(store.getState().some.title); // Optimize rendering of view. Only one DOM api call.
        break;
        default:
            updateView(store.getState()); // Some DOM api calls.
    }
});

Is it possible to get action and state in store.subscribe?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions