The event-emitter Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The event-emitter Reference Manual

This is the event-emitter Reference Manual, version 0.0.1, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 11:44:45 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

Event Emitter

Event Emitter provides an event mechanism like Node.js for Common Lisp objects.

Mostly ported from Node.js 'events' module.

Usage

;; Defining Event Emitter class.
(defclass person (event-emitter)
  ((name :initarg :name
         :reader name)))

(defvar *user*
  (make-instance 'person :name "Eitaro Fukamachi"))

;; Attach a event listener for an event ':say-hi'.
(on :say-hi *user*
    (lambda () (format t "Hi!")))

;; *user* says 'Hi!' when an event ':say-hi' is invoked.
(emit :say-hi *user*)
;-> Hi!

(emit :say-hi *user*)
;-> Hi!

(emit :say-hi *user*)
;-> Hi!

;; Attach an one time event listener.
(once :say-hi *user*
      (lambda ()
        (format t "How's it going?")))

;; 'Hi!' and "How's it going?" will be printed.
(emit :say-hi *user*)
;-> Hi!
;   How's it going?

;; *user* doens't say "How's it going?" anymore.
(emit :say-hi *user*)
;-> Hi!

(emit :say-hi *user*)
;-> Hi!

'event-glue'

There's already similar library named event-glue which you may like to know.

API

[Class] event-emitter

Base standard class for 'event-emitter's.

(defclass person (event-emitter)
  ((name :initarg :name)))

[Strucuture] event-emitter*

Base strucuture class for 'event-emitter's.

(defstruct (person :include event-emitter*)
  name)

[Function] (add-listener object event listener)
[Function] (on event object listener)

Adds a listener to the end of the listeners array for the specified event.

(on :connection server
    (lambda (stream) ...))

NOTE: add-listener and on takes 'object' and 'event' the opposite order.

[Function] (once event object listener)

Adds a one time listener for the event. This listener is invoked only the next time the event is fired, after which it is removed.

(once :connection server
      (lambda (stream) ...))

[Function] (remove-listener object event listener)

Removes a listener from the listener array for the specified event.

(defun connection-cb (stream)
  ...)

(on :connection server #'connection-cb)
(remove-listener server :connection #'connection-cb)

[Function] (remove-all-listeners object &optional event)

Removes all listeners, or those of the specified event.

(remove-all-listeners server)
(remove-all-listeners server :connection)

[Function] (listeners object event)

Returns an array of listeners for the specified event.

[Function] (emit event object &rest args)

Executes each of the listeners in order with the supplied arguments.

Returns T if the event had listeners, NIL otherwise.

[Function] (listener-count object event)

Returns the number of listeners for a given event.

Copyright

Copyright (c) 2014 Eitaro Fukamachi (e.arrows@gmail.com)

License

Licensed under the BSD 2-Clause License.


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 event-emitter

Author

Eitaro Fukamachi

License

BSD 2-Clause

Description

Event mechanism for Common Lisp objects

Version

0.0.1

Source

event-emitter.asd (file)

Component

src/event-emitter.lisp (file)


Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 event-emitter.asd

Location

event-emitter.asd

Systems

event-emitter (system)

Packages

event-emitter-asd


Previous: , Up: Lisp files   [Contents][Index]

3.1.2 event-emitter/src/event-emitter.lisp

Parent

event-emitter (system)

Location

src/event-emitter.lisp

Packages

event-emitter

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

4.1 event-emitter-asd

Source

event-emitter.asd

Use List

Previous: , Up: Packages   [Contents][Index]

4.2 event-emitter

Source

src/event-emitter.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Functions

Function: add-listener OBJECT EVENT LISTENER
Package

event-emitter

Source

src/event-emitter.lisp (file)

Function: emit EVENT OBJECT &rest ARGS
Package

event-emitter

Source

src/event-emitter.lisp (file)

Function: listener-count OBJECT EVENT
Package

event-emitter

Source

src/event-emitter.lisp (file)

Function: listeners OBJECT EVENT
Package

event-emitter

Source

src/event-emitter.lisp (file)

Function: on EVENT OBJECT LISTENER
Package

event-emitter

Source

src/event-emitter.lisp (file)

Function: once EVENT OBJECT LISTENER
Package

event-emitter

Source

src/event-emitter.lisp (file)

Function: remove-all-listeners OBJECT &optional EVENT
Package

event-emitter

Source

src/event-emitter.lisp (file)

Function: remove-listener OBJECT EVENT LISTENER
Package

event-emitter

Source

src/event-emitter.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Structures

Structure: event-emitter* ()
Package

event-emitter

Source

src/event-emitter.lisp (file)

Direct superclasses

structure-object (structure)

Direct slots
Slot: silo
Initform

(make-hash-table :test (quote eq))

Readers

event-emitter*-silo (function)

Writers

(setf event-emitter*-silo) (function)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Classes

Class: event-emitter ()
Package

event-emitter

Source

src/event-emitter.lisp (file)

Direct superclasses

standard-object (class)

Direct slots
Slot: silo
Initform

(make-hash-table :test (quote eq))


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Functions

Function: %add-listener OBJECT EVENT LISTENER
Package

event-emitter

Source

src/event-emitter.lisp (file)

Function: copy-event-emitter* INSTANCE
Package

event-emitter

Source

src/event-emitter.lisp (file)

Function: copy-listener INSTANCE
Package

event-emitter

Source

src/event-emitter.lisp (file)

Function: event-emitter*-p OBJECT
Package

event-emitter

Source

src/event-emitter.lisp (file)

Function: event-emitter*-silo INSTANCE
Function: (setf event-emitter*-silo) VALUE INSTANCE
Package

event-emitter

Source

src/event-emitter.lisp (file)

Function: listener-function INSTANCE
Function: (setf listener-function) VALUE INSTANCE
Package

event-emitter

Source

src/event-emitter.lisp (file)

Function: listener-once INSTANCE
Function: (setf listener-once) VALUE INSTANCE
Package

event-emitter

Source

src/event-emitter.lisp (file)

Function: listener-p OBJECT
Package

event-emitter

Source

src/event-emitter.lisp (file)

Function: make-event-emitter* &key (SILO SILO)
Package

event-emitter

Source

src/event-emitter.lisp (file)

Function: make-listener FUNCTION &key ONCE
Package

event-emitter

Source

src/event-emitter.lisp (file)

Function: silo OBJECT
Package

event-emitter

Source

src/event-emitter.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Structures

Structure: listener ()
Package

event-emitter

Source

src/event-emitter.lisp (file)

Direct superclasses

structure-object (structure)

Direct slots
Slot: function
Readers

listener-function (function)

Writers

(setf listener-function) (function)

Slot: once
Readers

listener-once (function)

Writers

(setf listener-once) (function)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   E   F   L  
Index Entry  Section

E
event-emitter.asd: The event-emitter<dot>asd file
event-emitter/src/event-emitter.lisp: The event-emitter/src/event-emitter<dot>lisp file

F
File, Lisp, event-emitter.asd: The event-emitter<dot>asd file
File, Lisp, event-emitter/src/event-emitter.lisp: The event-emitter/src/event-emitter<dot>lisp file

L
Lisp File, event-emitter.asd: The event-emitter<dot>asd file
Lisp File, event-emitter/src/event-emitter.lisp: The event-emitter/src/event-emitter<dot>lisp file

Jump to:   E   F   L  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   %   (  
A   C   E   F   L   M   O   R   S  
Index Entry  Section

%
%add-listener: Internal functions

(
(setf event-emitter*-silo): Internal functions
(setf listener-function): Internal functions
(setf listener-once): Internal functions

A
add-listener: Exported functions

C
copy-event-emitter*: Internal functions
copy-listener: Internal functions

E
emit: Exported functions
event-emitter*-p: Internal functions
event-emitter*-silo: Internal functions

F
Function, %add-listener: Internal functions
Function, (setf event-emitter*-silo): Internal functions
Function, (setf listener-function): Internal functions
Function, (setf listener-once): Internal functions
Function, add-listener: Exported functions
Function, copy-event-emitter*: Internal functions
Function, copy-listener: Internal functions
Function, emit: Exported functions
Function, event-emitter*-p: Internal functions
Function, event-emitter*-silo: Internal functions
Function, listener-count: Exported functions
Function, listener-function: Internal functions
Function, listener-once: Internal functions
Function, listener-p: Internal functions
Function, listeners: Exported functions
Function, make-event-emitter*: Internal functions
Function, make-listener: Internal functions
Function, on: Exported functions
Function, once: Exported functions
Function, remove-all-listeners: Exported functions
Function, remove-listener: Exported functions
Function, silo: Internal functions

L
listener-count: Exported functions
listener-function: Internal functions
listener-once: Internal functions
listener-p: Internal functions
listeners: Exported functions

M
make-event-emitter*: Internal functions
make-listener: Internal functions

O
on: Exported functions
once: Exported functions

R
remove-all-listeners: Exported functions
remove-listener: Exported functions

S
silo: Internal functions

Jump to:   %   (  
A   C   E   F   L   M   O   R   S  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   F   O   S  
Index Entry  Section

F
function: Internal structures

O
once: Internal structures

S
silo: Exported structures
silo: Exported classes
Slot, function: Internal structures
Slot, once: Internal structures
Slot, silo: Exported structures
Slot, silo: Exported classes

Jump to:   F   O   S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   E   L   P   S  
Index Entry  Section

C
Class, event-emitter: Exported classes

E
event-emitter: The event-emitter system
event-emitter: The event-emitter package
event-emitter: Exported classes
event-emitter*: Exported structures
event-emitter-asd: The event-emitter-asd package

L
listener: Internal structures

P
Package, event-emitter: The event-emitter package
Package, event-emitter-asd: The event-emitter-asd package

S
Structure, event-emitter*: Exported structures
Structure, listener: Internal structures
System, event-emitter: The event-emitter system

Jump to:   C   E   L   P   S