Skip to content

Event should be an object and contain type property #6

@mrroman

Description

@mrroman

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));

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions