Quark
#
Modules #
quark/actionquark/appquark/bubblesquark/bufferquark/checkboxquark/cssquark/ctrquark/dialogquark/eventquark/fontquark/fsquark/hashquark/httpquark/indexquark/jsonbquark/keyboardquark/mediaquark/navquark/netquark/osquark/pathquark/pkgquark/screenquark/stepperquark/storagequark/testquark/typesquark/utilquark/viewquark/windowquark/wsquark/_bufferquark/_commonquark/_eventquark/_extquark/_md5quark/_sha1quark/_sha256quark/_utilquark/_watching
Quark v1.3.0 Documentation
Table of Contents
-
quark/_event
- Class: Event
- Listen
- Listen2
- Class: EventNoticer
-
Class: Notification
- Notification
- notification.getNoticer(name)
- notification.hasNoticer(name)
- notification.addDefaultListener(name,listen)
- notification.addEventForward(name,noticer,id?)
- notification.addEventForwardOnce(noticer,id?)
- notification.trigger(name,data?)
- notification.triggerWithEvent(name,event)
- notification.removeEventListener(name,listen?,ctx?)
- notification.removeEventListenerWithCtx(ctx)
- notification.allNoticers()
- notification.triggerListenerChange(name,count,change)
- event(target,name)
quark/_event #
Class: Event #
Event #
The event data
@template<Sender,SendData>
event.returnValue #
The return value
returnValue:number
event.data #
The Data
@getdata:SendData
event.sender #
The sender
@getsender:Sender
event.constructor(data) #
@paramdata:SendData
Listen #
@callbackListen(this,evt)@template<E,Ctx>@paramthis:Ctx@paramevt:E
Listen2 #
@callbackListen2(self,evt)@template<E,Ctx>@paramself:Ctx@paramevt:E
Class: EventNoticer #
EventNoticer #
Event notifier, the core of event listener adding, deleting, triggering and notification
@template<E>
eventnoticer.name #
Event name
@getname:string
eventnoticer.sender #
@getsender:anyEvent sender
eventnoticer.length #
@getlength: Number of event listeners
eventnoticer.constructor(name,sender) #
@paramname:stringEvent name@paramsender:objectEvent sender@paramlisten: Listening Function@paramctxOrId?: Specify the listener function this or id alias@paramid?: Listener alias, can be deleted by id
For example:
var ctx = { a:100 }
var id = screen.onChange.on(function(ev) {
// Prints: 100
console.log(this.a)
}, ctx)
// Replace Listener
screen.onChange.on(function(ev) {
// Prints: replace 100
console.log('replace', this.a)
}, ctx, id)
@paramlisten: Listening Function@paramctxOrId?: Specify the listener function this or id alias@paramid?: Listener alias, can be deleted by id@paramlisten: Listening Function@paramctxOrId?: Specify the listener function this or id alias@paramid?: Listener alias, can be deleted by id@paramlisten: Listening Function@paramctxOrId?: Specify the listener function this or id alias@paramid: Listener alias, can be deleted by id
eventnoticer.triggerWithEvent(event) #
Notify all observers
@paramevent:E
eventnoticer.off(listen?,ctx?) #
Remove listener function
@paramlisten?:string|Function|object
It can be a listener function/id alias/context.
If no parameter is passed, all listeners will be uninstalled.@returnintReturns the number of deleted listeners@paramctx?:object
Class: Notification #
Notification #
This is a collection of events EventNoticer, event triggering and response center
Derived types inherited from it can use the @event keyword to declare member events
@template<E>
notification.getNoticer(name) #
@paramname:string@returnEventNoticer<E>
notification.hasNoticer(name) #
@paramname:string@returnbool
notification.addDefaultListener(name,listen) #
notification.addEventForward(name,noticer,id?) #
@paramname:string@paramnoticer:EventNoticer<E>@paramid?:string@returnstring
notification.addEventForwardOnce(noticer,id?) #
@paramnoticer:EventNoticer<E>@paramid?:string@returnstring
notification.trigger(name,data?) #
Trigger an event by event name --> [EventNoticer.trigger(data)]
@paramname:string@paramdata?:any
notification.triggerWithEvent(name,event) #
Trigger an event by name and Event --> EventNoticer.triggerWithEvent(event)
@paramname:string@paramevent:E
notification.removeEventListener(name,listen?,ctx?) #
notification.removeEventListenerWithCtx(ctx) #
Delete all listeners related to ctx on notification
Actually traverse and call the [EventNoticer.off(ctx)] method
For example:
import event from 'quark/event';
class TestNotification extends Notification {
\@event readonly onChange;
}
var notification = new TestNotification();
// Prints: responseonChange 0 100
notification.onChange = function(ev) { // add default listener
console.log('responseonChange 0', ev.data)
}
notification.triggerChange(100);
// Prints:
// responseonChange 0 200
// responseonChange 1
notification.onChange.on(function(ev) {
console.log('responseonChange 1')
})
notification.triggerWithEvent('change', new Event(200));
var noticer = notification.onChange;
noticer.off(0) // delete default listener
// Prints: responseonChange 1
notification.triggerChange();
@paramctx:object
notification.allNoticers() #
Get all of EventNoticer
@returnEventNoticer<E>[]
notification.triggerListenerChange(name,count,change) #
event(target,name) #
Typescript decorator
@decorator@paramtarget:any@paramname:string