mirror of
https://github.com/nasa/openmct.git
synced 2024-12-24 07:16:39 +00:00
[API] Exemplify mutate/observe
This commit is contained in:
parent
0e7d812db7
commit
616e2b4d77
25
API.md
25
API.md
@ -152,9 +152,6 @@ openmct.composition.addProvider({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Using Open MCT
|
## Using Open MCT
|
||||||
|
|
||||||
When implementing new features, it is useful and sometimes necessary to
|
When implementing new features, it is useful and sometimes necessary to
|
||||||
@ -193,6 +190,28 @@ a view (or part of a view) selectable:
|
|||||||
openmct.gestures.selectable(myHtmlElement, myDomainObject);
|
openmct.gestures.selectable(myHtmlElement, myDomainObject);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Working with Domain Objects
|
||||||
|
|
||||||
|
The [object API]{@link module:openmct.ObjectAPI} provides useful methods
|
||||||
|
for working with domain objects.
|
||||||
|
|
||||||
|
To make changes to a domain object, use the
|
||||||
|
[`mutate`]{@link module:openmct.ObjectAPI#mutate} method:
|
||||||
|
|
||||||
|
```
|
||||||
|
openmct.objects.mutate(myDomainObject, "name", "New name!");
|
||||||
|
```
|
||||||
|
|
||||||
|
Making modifications in this fashion allows other usages of the domain
|
||||||
|
object to remain up to date using the
|
||||||
|
[`observe`]{@link module:openmct.ObjectAPI#observe} method:
|
||||||
|
|
||||||
|
```
|
||||||
|
openmct.objects.observe(myDomainObject, "name", function (newName) {
|
||||||
|
myLabel.textContent = newName;
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
## Plugins
|
## Plugins
|
||||||
|
|
||||||
While you can register new features with Open MCT directly, it is generally
|
While you can register new features with Open MCT directly, it is generally
|
||||||
|
Loading…
Reference in New Issue
Block a user