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

Event should be an object and contain type property #6

Open
mrroman opened this issue Sep 6, 2016 · 0 comments
Open

Event should be an object and contain type property #6

mrroman opened this issue Sep 6, 2016 · 0 comments

Comments

@mrroman
Copy link
Owner

mrroman commented Sep 6, 2016

Currently events are just strings and their properties are passed as additional parameters to dispatch. This can lead to hard and unmaintainable code.

We should change it to objects with type property, so they could be generated with function. Functions presence and identity can be statically checked with linters.

Old (bad):

store.dispatch('add-item', item);

New (good):

const addItem = (item) => {
    return {
        type: 'add-item',
        item
    };
};

store.dispatch(addItem(item));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant