Skip to content
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

Add Flow definition file. #111

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions src/index.flow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
declare export interface FluxStandardAction<Payload, Meta>{
/**
* The `type` of an action identifies to the consumer the nature of the action that has occurred.
* Two actions with the same `type` MUST be strictly equivalent (using `===`)
*/
type: string,

/**
* The optional `payload` property MAY be any type of value.
* It represents the payload of the action.
* Any information about the action that is not the type or status of the action should be part of the `payload` field.
* By convention, if `error` is `true`, the `payload` SHOULD be an error object.
* This is akin to rejecting a promise with an error object.
*/
payload?: Payload,

/**
* The optional `error` property MAY be set to true if the action represents an error.
* An action whose `error` is true is analogous to a rejected Promise.
* By convention, the `payload` SHOULD be an error object.
* If `error` has any other value besides `true`, including `undefined`, the action MUST NOT be interpreted as an error.
*/
error?: boolean,

/**
* The optional `meta` property MAY be any type of value.
* It is intended for any extra information that is not part of the payload.
*/
meta?: Meta
}

declare export type ErrorFluxStandardAction<CustomError, Meta>= {
error: true
} & FluxStandardAction

/**
* Alias for FluxStandardAction.
*/
declare export type FSA<Payload, Meta>= FluxStandardAction<Payload, Meta>;

/**
* Alias for ErrorFluxStandardAction.
*/
declare export type ErrorFSA<CustomError, Meta>= ErrorFluxStandardAction<CustomError, Meta>;

/**
* Returns `true` if `action` is FSA compliant.
*/
declare export function isFSA<Payload, Meta>(action: any): FluxStandardAction

/**
* Returns `true` if `action` is FSA compliant error.
*/
declare export function isError<CustomError, Meta>(action: any): ErrorFluxStandardAction