Module

Node.EventEmitter.TypedEmitter

Package
purescript-node-event-emitter
Repository
jordanmartinez/purescript-node-event-emitter

#TypedEmitter Source

newtype TypedEmitter :: Emittable -> Handlers -> Row Type -> Typenewtype TypedEmitter e h r

#new Source

new :: forall r all. Proxy r -> Effect (TypedEmitter CanEmit CanHandle all)

#asEmitterOnly Source

asEmitterOnly :: forall handler all. TypedEmitter CanEmit handler all -> TypedEmitter NoEmit handler all

#asHandlerOnly Source

asHandlerOnly :: forall emit all. TypedEmitter emit CanHandle all -> TypedEmitter emit NoHandle all

#setMaxListeners Source

setMaxListeners :: forall emit handler row. Int -> TypedEmitter emit handler row -> Effect Unit

#setUnlimitedListeners Source

setUnlimitedListeners :: forall emit handler row. TypedEmitter emit handler row -> Effect Unit

#listenersLength Source

listenersLength :: forall e h sym a tail row. Cons sym a tail row => IsSymbol sym => Proxy sym -> TypedEmitter e h row -> Effect Int

#on Source

on :: forall emit sym fn tail row effectFn. Cons sym fn tail row => UnsafeOnEvent fn effectFn => IsSymbol sym => Proxy sym -> fn -> TypedEmitter emit CanHandle row -> Effect effectFn

#addEventListener Source

addEventListener :: forall emit sym fn tail row effectFn. Cons sym fn tail row => UnsafeOnEvent fn effectFn => IsSymbol sym => Proxy sym -> fn -> TypedEmitter emit CanHandle row -> Effect effectFn

#off Source

off :: forall emit sym fn tail row effectFn. Cons sym fn tail row => HandlerFunction fn effectFn => UnsafeOffEvent effectFn => IsSymbol sym => Proxy sym -> effectFn -> TypedEmitter emit CanHandle row -> Effect Unit

#removeEventListener Source

removeEventListener :: forall emit sym fn tail row effectFn. Cons sym fn tail row => HandlerFunction fn effectFn => UnsafeOffEvent effectFn => IsSymbol sym => Proxy sym -> effectFn -> TypedEmitter emit CanHandle row -> Effect Unit

#subscribe Source

subscribe :: forall emit sym fn tail row effectFn. Cons sym fn tail row => UnsafeOnEvent fn effectFn => UnsafeOffEvent effectFn => IsSymbol sym => Proxy sym -> fn -> TypedEmitter emit CanHandle row -> Effect (Effect Unit)

#once Source

once :: forall emit sym fn tail row. Cons sym fn tail row => UnsafeOnceListener fn => IsSymbol sym => Proxy sym -> fn -> TypedEmitter emit CanHandle row -> Effect Unit

#withEmit Source

withEmit :: Effect Boolean -> Effect Boolean

Helps with type inference due to the overloaded nature of emit.

#emit Source

emit :: forall handler sym fn tail row argsThenEffectBoolean. Cons sym fn tail row => EmitterFunction fn argsThenEffectBoolean => UnsafeEmit argsThenEffectBoolean => IsSymbol sym => Proxy sym -> TypedEmitter CanEmit handler row -> argsThenEffectBoolean

Since the return type is polymorphic to allow one to easily add as many arguments as are needed using the same function, type inference suffers. To workaround that issue, precede all calls with withEmit. For example

b <- withEmit $ emit (Proxy :: _ "eventName") emitter arg1 arg2 arg3
void $ withEmit $ emit (Proxy :: _ "eventName") emitter arg1 arg2 arg3

Otherwise, you'll have to write this to deal with compiler errors:

(_ :: Boolean) <- emit (Proxy :: _ "eventName") emitter arg1 arg2 arg3
map (\(_ :: Boolean) -> unit) $ emit (Proxy :: _ "eventName") emitter arg1 arg2 arg3

#EmitterFunction Source

class EmitterFunction callbackFn emitterArgs | callbackFn -> emitterArgs

Determines the number and type of args to pass into the emit function based on the number and type of args received by the callback type associated with that label in the row.

Instances

#HandlerFunction Source

class HandlerFunction callbackFn handlerFn | callbackFn -> handlerFn

Instances

Re-exports from Node.EventEmitter

#NoHandle Source

#NoEmit Source

data NoEmit :: Emittabledata NoEmit

#Handlers Source

#Emittable Source

#CanHandle Source

#CanEmit Source

#UnsafeEmit Source

class UnsafeEmit a 

Instances

#UnsafeOnEvent Source

class UnsafeOnEvent callbackFn callbackEffectFn | callbackFn -> callbackEffectFn

Instances

#UnsafeOnceListener Source

class UnsafeOnceListener callbackFn 

Instances