new Amoeba(parent, p)
Creates a new Amoeba
Parameters:
Name | Type | Description |
---|---|---|
parent |
Amoeba | The parent amoeba |
p |
String | Path for current amoeba |
Members
Methods
-
as(Object) → {Amoeba}
-
Route amoeba path to Object
Parameters:
Name Type Description Object
Object for route Returns:
self for chain execution- Type
- Amoeba
-
emit(event, data) → {Amoeba}
-
Emit event
Parameters:
Name Type Description event
String Event to emit data
Object Event data Returns:
self for chain execution- Type
- Amoeba
-
handlers(type, path) → {Array}
-
Find handlers by type or by type and path
Parameters:
Name Type Description type
String Type of handle path
String Used path Returns:
All founded handlers- Type
- Array
-
invoke(method, params, callback) → {Amoeba}
-
Invoke method
Parameters:
Name Type Argument Description method
String Method name params
Object <optional>
Object or Array callback
function <optional>
Callback function for async methods Returns:
self for chain execution- Type
- Amoeba
-
on(event, callback) → {Amoeba}
-
Add event listener
Parameters:
Name Type Description event
String Event to listen. Can be mask. callback
function Callback function Returns:
self for chain execution- Type
- Amoeba
-
path(p) → {Amoeba}
-
Method return new Amoeba accroding path
Parameters:
Name Type Description p
String Path Returns:
new created amoeba- Type
- Amoeba
Example
var amoeba = new Amoeba(); amoeba.path("chat").on("message", function(){});
-
root() → {Amoeba}
-
Method return root amoeba
Returns:
The root amoeba- Type
- Amoeba
-
use(type, handler) → {Amoeba}
-
Add middleware logic
Parameters:
Name Type Description type
String Type of handler. before_invoke | after_invoke | before_event handler
function Handler Returns:
self for chain execution- Type
- Amoeba