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

Convert src/ to TypeScript #68

Merged
merged 25 commits into from Feb 18, 2017
Commits
Jump to file or symbol
Failed to load files and symbols.
+81 −77
Diff settings

Always

Just for now

Viewing a subset of changes. View all

Convert DispatcherPayloadMeta to TypeScript

  • Loading branch information...
saneyuki committed Feb 16, 2017
commit d83ccc11cf69f807e99b54add0de7ba469953cfb

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,81 @@
// LICENSE : MIT
"use strict";
export type UseCase = any; // FIXME
export type Dispatcher = any; // FIXME
export interface DispatcherPayloadMetaArgs {
useCase?: UseCase;
dispatcher?: Dispatcher | Dispatcher;
parentUseCase?: UseCase | null;
/**
* true if the payload object is generated by Almin.
*/
isTrusted?: boolean;
}
/**
* DispatcherPayloadMeta is a meta object for dispatcher.
* If `isTrusted` is true, the object is created by System(= Almin).
* The user can get this meta object together with dispatched `payload` object
* @example
* context.onDispatch((payload, meta) => {
* console.log(meta);
* });
*/
export default class DispatcherPayloadMeta {
/**
* A reference to the useCase/dispatcher to which the payload was originally dispatched.
*/
readonly useCase: UseCase | null;
/**
* A dispatcher of the payload
* In other word, the payload is dispatched by `this.dispatcher`
*
* ## dispatcher in a useCase
*
* In following example, this.dispatcher is same with this.useCase.
*
* class Example extends UseCase {
* execute(){
* this.dispatch({ type })
* ^^^^
* === this dispatcher === this.useCase
* }
* }
*/
readonly dispatcher: UseCase | Dispatcher | null;
/**
* A parent useCase of the `this.useCase`,
* When useCase is nesting, parentUseCase is a UseCase.
*/
readonly parentUseCase: UseCase | Dispatcher | null;
/**
* A timeStamp is created time of the meta.
*/
readonly timeStamp: number;
/**
* If the payload object is generated by Almin, true
* The use can use it for detecting "Is the payload generated by system(almin)?".
* It is similar with https://www.w3.org/TR/DOM-Level-3-Events/#trusted-events
*/
readonly isTrusted: boolean;
constructor({
useCase,
dispatcher,
parentUseCase,
isTrusted
}: DispatcherPayloadMetaArgs = {}) {
this.useCase = useCase || null;
this.dispatcher = (dispatcher === undefined) ? null : dispatcher;
this.parentUseCase = parentUseCase || null;
this.timeStamp = Date.now();
this.isTrusted = !!isTrusted;
}
}
ProTip! Use n and p to navigate between commits in a pull request.