跳转到内容

Observable

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

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

src/Observable.ts:167


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

src/Observable.ts:122

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

src/Observable.ts:128

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

src/Observable.ts:133

off()

off(): void

unsubscribe all event listeners

Returns

void

Defined in

src/Observable.ts:137


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

src/Observable.ts:23

on(handlers)

on(handlers): VoidFunction

Parameters

handlers: EventRegistryObject<EventSpec>

Returns

VoidFunction

Defined in

src/Observable.ts:27


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

src/Observable.ts:62

once(handlers)

once(handlers): VoidFunction

Parameters

handlers: EventRegistryObject<EventSpec>

Returns

VoidFunction

Defined in

src/Observable.ts:66