Skip to content

Observable

Defined in: src/Observable.ts:11

Tutorial

http://fabricjs.com/fabric-intro-part-2#events

See

demo

Type Parameters

EventSpec

Constructors

new Observable()

new Observable<EventSpec>(): Observable<EventSpec>

Returns

Observable<EventSpec>

Methods

fire()

fire<K>(eventName, options?): void

Defined in: src/Observable.ts:167

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


off()

Call Signature

off<K>(eventName): void

Defined in: src/Observable.ts:122

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

Call Signature

off<K>(eventName, handler): void

Defined in: src/Observable.ts:128

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

Call Signature

off(handlers): void

Defined in: src/Observable.ts:133

unsubscribe event listeners

Parameters
handlers

EventRegistryObject<EventSpec>

handlers key/value pairs (eg. {‘after:render’: handler, ‘selection:cleared’: handler})

Returns

void

Call Signature

off(): void

Defined in: src/Observable.ts:137

unsubscribe all event listeners

Returns

void


on()

Call Signature

on<K, E>(eventName, handler): VoidFunction

Defined in: src/Observable.ts:23

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

Call Signature

on(handlers): VoidFunction

Defined in: src/Observable.ts:27

Observes specified event

Parameters
handlers

EventRegistryObject<EventSpec>

key/value pairs (eg. {‘after:render’: handler, ‘selection:cleared’: handler})

Returns

VoidFunction

disposer

Alias

on


once()

Call Signature

once<K, E>(eventName, handler): VoidFunction

Defined in: src/Observable.ts:62

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

Call Signature

once(handlers): VoidFunction

Defined in: src/Observable.ts:66

Observes specified event once

Parameters
handlers

EventRegistryObject<EventSpec>

key/value pairs (eg. {‘after:render’: handler, ‘selection:cleared’: handler})

Returns

VoidFunction

disposer

Alias

once