Skip to content

Good Emitter Hygiene? #127

@mailok

Description

@mailok

Hello everyone, I would like to make a proposal or a question.
Recently I saw the video Good Action Hygiene by Mike Ryan and Emitter pattern from ngxs-labs, and I would like to get what Mike Ryan talked about the actions but without the actions.

For example i have this in two different components:

Component Dashboard:

@Emitter(BurgerState.addBurguer)
public emitBurguerFromDashboard: Emittable<Burger>;

Component BurgerPage:

@Emitter(BurgerState.addBurger)
public emitBurgerFromBurgerPage: Emittable<Burger>;

but I want there to be only one implementation in the state, which in this case would be:

    @Receiver()
    public static addBurguer(ctx: StateContext<BurgerStateModel>, action: EmitterAction<Burger>) {
      // logic.....
    }

How to have all this but at the same time be able to see in my devtools:

[Dashboard] add burguer
[Burger Page] add burguer

Of course, without defining actions.

If it is not possible at this time, It would be great if I emit a payload and the source from which that payload came out, for example, something like that:

@Emitter({receiver: BurgerState.addBurguer, source: '[Dashboard] add burguer'})
public emitBurguerFromDashboard: Emittable<Burguer>;

@Emitter({receiver: BurgerState.addBurger, source: '[Burger Page] add burguer'})
public emitBurgerFromBurgerPage: Emittable<Burger>;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions