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 ObjectObject for route Returns:
self for chain execution- Type
- Amoeba
-
emit(event, data) → {Amoeba}
-
Emit event
Parameters:
Name Type Description eventString Event to emit dataObject 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 typeString Type of handle pathString Used path Returns:
All founded handlers- Type
- Array
-
invoke(method, params, callback) → {Amoeba}
-
Invoke method
Parameters:
Name Type Argument Description methodString Method name paramsObject <optional>
Object or Array callbackfunction <optional>
Callback function for async methods Returns:
self for chain execution- Type
- Amoeba
-
on(event, callback) → {Amoeba}
-
Add event listener
Parameters:
Name Type Description eventString Event to listen. Can be mask. callbackfunction Callback function Returns:
self for chain execution- Type
- Amoeba
-
path(p) → {Amoeba}
-
Method return new Amoeba accroding path
Parameters:
Name Type Description pString 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 typeString Type of handler. before_invoke | after_invoke | before_event handlerfunction Handler Returns:
self for chain execution- Type
- Amoeba