Workspace Context
All of the workspaces have the possibility to access the context, where it is possible to find the info of the components, the workspace and perform operations like get, set and subscribe
Can have access in two ways:
-
Clicking on the button "set default value", and shows the default parameters of the functions, that includes the workspaceContext
-
If a function already exists and the context parameter isn't declared, it could be added manually.
WorkspaceContext is a function that has three main properties:
- Set
- Get
- Subscribe
- Definition
- ComponentDefinition
It allows you to set a context variable in a workspace and access that variable in another workspace under the same routing scope.
Set
Used to set the the value in a variable to use posteriorly
Parameter | Type | Required | Description |
---|---|---|---|
name | String | true | Name to reference the valued passed |
value | Any | true | Any type of value can be passed |
workspaceContext.set("name", value);
Variable updateClient set at function onInitialized, to save the component
Get
Used to get the value saved previously
Parameter | Type | Required | Description |
---|---|---|---|
name | String | true | Name of the reference passed previously |
workspaceContext.get("name");
Getting the value saved at variable updateClient
Subscribe
Subscribe the context's variable you want to listen
Parameter | Type | Required | Description |
---|---|---|---|
name | String | true | Name to reference the passed value |
callBack | String | true | A callBack function |
workspaceContext.get('name', callBack function(){});
- Subscribe the variable updateClient defined at the beggining. In this case the value was used to show a pop-up if the client exists
- Use the new value to make the necessary changes everytime the variable value is updated.