Quark
#
Modules #
quark/action
quark/app
quark/bubbles
quark/buffer
quark/checkbox
quark/css
quark/ctr
quark/dialog
quark/event
quark/font
quark/fs
quark/http
quark/index
quark/keyboard
quark/media
quark/nav
quark/os
quark/path
quark/pkg
quark/screen
quark/stepper
quark/storage
quark/test
quark/types
quark/util
quark/view
quark/window
quark/_common
quark/_event
quark/_ext
quark/_util
Quark v1.2.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
@get
data
:SendData
event.sender #
The sender
@get
sender
:Sender
event.constructor(data) #
@param
data
:SendData
Listen #
@callback
Listen(this,evt)
@template
<E
,Ctx
>@param
this
:Ctx
@param
evt
:E
Listen2 #
@callback
Listen2(self,evt)
@template
<E
,Ctx
>@param
self
:Ctx
@param
evt
:E
Class: EventNoticer #
EventNoticer #
Event notifier, the core of event listener adding, deleting, triggering and notification
@template
<E
>
eventnoticer.name #
Event name
@get
name
:string
eventnoticer.sender #
@get
sender
:any
Event sender
eventnoticer.length #
@get
length
: Number of event listeners
eventnoticer.constructor(name,sender) #
@param
name
:string
Event name@param
sender
:object
Event sender@param
listen
: Listening Function@param
ctxOrId?
: Specify the listener function this or id alias@param
id?
: 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)
@param
listen
: Listening Function@param
ctxOrId?
: Specify the listener function this or id alias@param
id?
: Listener alias, can be deleted by id@param
listen
: Listening Function@param
ctxOrId?
: Specify the listener function this or id alias@param
id?
: Listener alias, can be deleted by id@param
listen
: Listening Function@param
ctxOrId?
: Specify the listener function this or id alias@param
id
: Listener alias, can be deleted by id
eventnoticer.triggerWithEvent(event) #
Notify all observers
@param
event
:E
eventnoticer.off(listen?,ctx?) #
Remove listener function
@param
listen?
:string
|Function
|object
It can be a listener function/id alias/context.
If no parameter is passed, all listeners will be uninstalled.@return
int
Returns the number of deleted listeners@param
ctx?
: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) #
@param
name
:string
@return
EventNoticer
<E
>
notification.hasNoticer(name) #
@param
name
:string
@return
bool
notification.addDefaultListener(name,listen) #
notification.addEventForward(name,noticer,id?) #
@param
name
:string
@param
noticer
:EventNoticer
<E
>@param
id?
:string
@return
string
notification.addEventForwardOnce(noticer,id?) #
@param
noticer
:EventNoticer
<E
>@param
id?
:string
@return
string
notification.trigger(name,data?) #
Trigger an event by event name --> [EventNoticer.trigger(data)
]
@param
name
:string
@param
data?
:any
notification.triggerWithEvent(name,event) #
Trigger an event by name and Event
--> EventNoticer.triggerWithEvent(event)
@param
name
:string
@param
event
: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();
@param
ctx
:object
notification.allNoticers() #
Get all of EventNoticer
@return
EventNoticer
<E
>[]
notification.triggerListenerChange(name,count,change) #
event(target,name) #
Typescript decorator
@decorator
@param
target
:any
@param
name
:string