Proposal: Introduce `meta` object to Dispatcher#dispatch(payload, meta) #61

Closed
azu opened this Issue Nov 20, 2016 · 2 comments

Comments

Projects
None yet
1 participant
@azu
Member

azu commented Nov 20, 2016

Motivation

Currently, Dispatcher#dispatch(payload) can dispatch some payload.
But, The receiver of payload can't know that is the payload come from?

The feature is needed to implementdispatch logging correctly.

Propose

Introduce Dispatcher#dispatch(payload, meta)
dispatch's second argument is contextual object.
This meta object contains:

  • useCase: current UseCase
  • parentUseCase : parent UseCase
  • error?: error object when throwError To be payload.
  • args?: arguments when willExecute To be payload.
  • results? : results when didExecute . maybe rename To be payload.
  • timeStamp: timeStamp

meta means that this is created by almin. ( Can we allow the user to use meta?)

Breaking Change

They should be changed in the proposal:

Context#onDispatch((payload, meta) => {});
Context#onWillExecuteEachUseCase((payload, meta) => { });
Context#onCompleteEachUseCase((payload, meta) => { });
Context#onDidExecuteEachUseCase((payload, meta) => { });
Context#onErrorDispatch((payload, meta) => {});
  • payload: DispatcherPayload
    • type: * - maybe String or Symbol
    • error?: error object when throwError
    • args?: arguments when willExecute
    • results? : results when didExecute . maybe rename. require more better name
  • meta: Object
    • useCase: current UseCase
    • parentUseCase : parent UseCase
    • timeStamp: timeStamp

📝 Note: vs. DOM Event

DOM Event has all property in own event object.
event.type, event.target, event.timeStamp and so....

The difference between DOM Event and Almin payload(DispatcherPayload).

DOM Event object is not must that added Custom property like

event.customeProp = 42

But, Almin's payload must that added Custom property like

{ type : "custom" , customProps: 42 }

Separated meta object is required to grow ecosystem of Almin.
meta object is always attached by Almin core system.
In other word, the user can't attached meta obejct.

@azu azu added the Proposal label Nov 20, 2016

azu added a commit that referenced this issue Nov 20, 2016

feat(Dispatcher): Introduce DispatcherPayloadMeta
- Add DispatcherPayloadMeta.js
- Dispatcher User dispatch `payload` and `meta`.

refs #61
@azu

This comment has been minimized.

Show comment
Hide comment
@azu

azu Feb 1, 2017

Member

📝 UseCase will need id.

Member

azu commented Feb 1, 2017

📝 UseCase will need id.

@azu azu referenced this issue Feb 16, 2017

Closed

Almin 0.10 Roadmap #67

@azu

This comment has been minimized.

Show comment
Hide comment
@azu

azu Feb 18, 2017

Member

Merged #62

Member

azu commented Feb 18, 2017

Merged #62

@azu azu closed this Feb 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment