Observable
Tutorial
http://fabricjs.com/fabric-intro-part-2#events
See
Type Parameters
• EventSpec
Constructors
new Observable()
new Observable<
EventSpec
>():Observable
<EventSpec
>
Returns
Observable
<EventSpec
>
Methods
fire()
fire<
K
>(eventName
,options
?):void
Fires event with an optional options object
Type Parameters
• K extends string
| number
| symbol
Parameters
• eventName: K
Event name to fire
• options?: EventSpec
[K
]
Options object
Returns
void
Defined in
off()
off(eventName)
off<
K
>(eventName
):void
Unsubscribe all event listeners for eventname. Do not use this pattern. You could kill internal fabricJS events. We know we should have protected events for internal flows, but we don’t have yet
Type Parameters
• K extends string
| number
| symbol
Parameters
• eventName: K
event name (eg. ‘after:render’)
Returns
void
Defined in
off(eventName, handler)
off<
K
>(eventName
,handler
):void
unsubscribe an event listener
Type Parameters
• K extends string
| number
| symbol
Parameters
• eventName: K
event name (eg. ‘after:render’)
• handler: TEventCallback
<any
>
event listener to unsubscribe
Returns
void
Defined in
off(handlers)
off(
handlers
):void
unsubscribe event listeners
Parameters
• handlers: EventRegistryObject
<EventSpec
>
handlers key/value pairs (eg. {‘after:render’: handler, ‘selection:cleared’: handler})
Returns
void
Defined in
off()
off():
void
unsubscribe all event listeners
Returns
void
Defined in
on()
on(eventName, handler)
on<
K
,E
>(eventName
,handler
):VoidFunction
Observes specified event
Type Parameters
• K extends string
| number
| symbol
• E
Parameters
• eventName: K
Event name (eg. ‘after:render’)
• handler: TEventCallback
<E
>
Function that receives a notification when an event of the specified type occurs
Returns
VoidFunction
disposer
Alias
on
Defined in
on(handlers)
on(
handlers
):VoidFunction
Parameters
• handlers: EventRegistryObject
<EventSpec
>
Returns
VoidFunction
Defined in
once()
once(eventName, handler)
once<
K
,E
>(eventName
,handler
):VoidFunction
Observes specified event once
Type Parameters
• K extends string
| number
| symbol
• E
Parameters
• eventName: K
Event name (eg. ‘after:render’)
• handler: TEventCallback
<E
>
Function that receives a notification when an event of the specified type occurs
Returns
VoidFunction
disposer
Alias
once
Defined in
once(handlers)
once(
handlers
):VoidFunction
Parameters
• handlers: EventRegistryObject
<EventSpec
>
Returns
VoidFunction