pending
Package defines pending value abstraction in form of three [polymorphic methods][method], where each one can be extended per type. This abstraction likely to be used in conjunction with watchable.
isPending
pending/is module provides method that must
return true
for all pending values and return false
for all others. Method
has default implementation that returns false
. Types that wish to implement
this abstraction should return true
while value is considered pending.
var isPending = { this_result = this this_pending = true this_listeners = }isPending // => false // => false // => true
await
pending/await module provides method that can be used to register listener that must be called once value is no longer pending. Method has default implementation that calls listener immediately with a value since non of the built-in types considered to be pending. Custom types wishing to implement this abstraction should define this method such that all registered listeners will be invoked with a delivery value once they it transitions to non-pending state.
var await = await3 consolelog // => info: 3await{} consolelog // => info: {} await
deliver
pending/deliver module provides method that can is supposed to doliver pending values and transition them form pending to non-pending state, such transition supposed to happen only once. Method does not comes with default implementation as non of the built-ins are considered pending, there for attempt to call it on values that don't implement it will throw. Custom types wishing to implement pending abstraction may choose to implement it, although it's optional since some pending values may be observable but not deliverable.
var deliver = deliver
Install
npm install pending