Application structure that allows interconnection with other applications (combining routes and expressing parent/child relationships)
import {
Application, Register, extendClass, getChildrenWithContext
} from "sp-application";
Defines the interface needed to connect new components/stores/routes etc. the to application as a whole. Note in the example that decorators are called with "@" not "//@", but the documentation tool will accidently parse it.
//@application()
class Foo {
static get routes() {
return {
"/myfoos": {
"/": "openIndex",
"/:id": "openDetailPage"
}
};
}
static get signals() {
return {
"openIndex": [setPage],
"openDetailPage": [setPage, fetchStuff]
};
}
static get store() {
return {
hai: true
};
}
}
Variables to be added to the store
{
storeData: "foo"
}
#### `Application.routes() -> Object` Cerebral router signals paths
{
"/messages/": "messageList",
"/messages/:id/": "message"
}
#### `Application.signals() -> Object` Signal/action pairings for cerebral and cerebral router
{
"action": [action1, action2, action3]
}
Adds the parent value to a class. Used to set a child application to a parent application. For example, if I have the `appointments` app, after using this decorator @parent("ui"), it changes it to become "ui.appointments". Note in the example that decorators are called with "@" not "//@", but the documentation tool will accidently parse it.
Type | Parameter | Description |
---|---|---|
String | value |
//@parent("parentApp")
//@application()
class MyApp {
}
#### `Decorators.application([String value]) -> Function` Register an application, adding it to the application runner. Note in the example that decorators are called with "@" not "//@", but the documentation tool will accidently parse it.
Type | Parameter | Description |
---|---|---|
String | value |
Name of the application (must be unique). If not supplied, then uses the lowercase name of the class |
//@application()
class MyApp {
}
Global registration class. Used for dynamically importing applications and middleware on startup.
Unregister a module
Type | Parameter | Description |
---|---|---|
String | name |
#### `Register.import((string|string[]) paths) -> Promise` Dynamically loads a module
Type | Parameter | Description |
---|---|---|
(string|string[]) | paths |
Module(s) to import |
#### `Register.get(String name)` Return a registered plugin
Type | Parameter | Description |
---|---|---|
String | name |
#### `Register.register(String name, Function module)` Register a plugin
Type | Parameter | Description |
---|---|---|
String | name |
|
Function | module |
##### **Methods** #### `ApplicationRunner.add(String name, Application module)`
Type | Parameter | Description |
---|---|---|
String | name |
|
Application | module |
#### `ApplicationRunner.remove(String name)`
Type | Parameter | Description |
---|---|---|
String | name |
#### `ApplicationRunner.createRoutes() -> Object`
#### `ApplicationRunner.createSignals() -> Object`
#### `ApplicationRunner.createStore() -> Object`
Copies all static and prototype methods/fields from classB to classA IF they don't already exist. Consider this like _.defaults in lodash for classes.
Type | Parameter | Description |
---|---|---|
Function | classA |
The class to extend |
Function | classB |
The class we're copying |