Skip to content

Improve section about Non-Parent-Child communication & Event Bus #750

Open
@LinusBorg

Description

@LinusBorg

Currently, we recommend using an event bus for non-parent-child communication here:

https://vuejs.org/v2/guide/components.html#Non-Parent-Child-Communication

While we do state, after the example:

In more complex cases, you should consider employing a dedicated state-management pattern.

... from what I see on the forum, SO, reddit and so on, this pattern is often abused to do things that a small global state object can solve much better, and more reliably.

I think we should add a clearer warning that this pattern is best reserved for edge cases and recommend a "global state" pattern first.

Also, the current example lacks information about the need to use $off to un-register event listeners, e.g. when a component that did set up this listener is destroyed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions