callback.flow
Just Callback<x, a>
interface definition for use with flow projects that interface with nodejs callback based APIs. Callback<x, a>
is a function that can be used to report success or failure of the async operation:
If operation is succeeds callback must be invoked with two arguments first of type either null|void
and second of type a
- callback(null, value)
If operation is fails callback must be invoked with single argument of type x
- callback(error)
Please note that success type paramater is optional and defaults to void
there for callbacks that don't pass data back can be typed as Callback<string>
and also be invoked as callback()
to report success and callback('Oops')
to report failure.
Usage
const readAsync = address: string callback: Callback<Error string>: { if // .... else }
Install
npm install callback.flow