Skip to content

Commit 8c1ea1d

Browse files
authored
docs(js): Add new enablePerfMarks option and viewModelName property (#590)
Adds: - new `enablePerfMarks` option to params doc (needs an update, but that should be separate) - Added note about getting an instance's view model name in the web databinding docs.
1 parent 9348dc9 commit 8c1ea1d

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ The basic scope naming convention for the runtimes is to use the root directory
6666

6767
## Previews
6868

69-
Rive's documentation is powered by [Mintlify](https://mintlify.com). You can preview your changes [locally](https://mintlify.com/docs/development), or via a preview link after creating a pull request.
69+
Rive's documentation is powered by [Mintlify](https://mintlify.com). You can preview your changes [locally](https://www.mintlify.com/docs/quickstart#make-your-first-change), or via a preview link after creating a pull request.
7070

7171
### Local Previews
7272

73-
See Mintlify's official documentation on [Local Development](https://mintlify.com/docs/development) for more information on how to preview changes locally.
73+
See Mintlify's official documentation on [Local Development](https://www.mintlify.com/docs/quickstart#make-your-first-change) for more information on how to preview changes locally.
7474

7575
When previewing locally, make sure to run `mintlify broken-links` before creating your pull request to verify that there are no broken links.
7676

runtimes/web/data-binding.mdx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,28 @@ const r = new rive.Rive({
108108
});
109109
```
110110

111+
### Get View Model from Instance
112+
113+
When working with view model instances, you may want to get a reference to the view model the instance came from so you can dynamically create more instances of the same type (i.e. creating instances from lists).
114+
To do so, first grab the name of the view model the instance came from via the `.viewModelName` property:
115+
```ts
116+
const vmi = r.viewModelInstance;
117+
const vmName = vmi.viewModelName;
118+
```
119+
120+
Then, once you have the name, you can get a reference to the view model itself and create instances as needed.
121+
```ts
122+
const vmi = r.viewModelInstance;
123+
const mainListProp = vmi.list("todos") as ViewModelInstanceList;
124+
const vmName = mainListProp.instanceAt(0)?.viewModelName;
125+
126+
const itemVmReference = r.viewModelByName(vmName);
127+
const instanceCopies = [];
128+
for (let i = 0; i < 10; i++) {
129+
instanceCopies.push(itemVmReference.defaultInstance());
130+
}
131+
```
132+
111133
<Properties />
112134

113135
<ListingProperties />

runtimes/web/rive-parameters.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export interface RiveParameters {
3636
onStateChange?: EventCallback,
3737
onAdvance?: EventCallback,
3838
assetLoader?: AssetLoadCallback,
39+
enablePerfMarks?: boolean,
3940
}
4041
```
4142

@@ -83,6 +84,7 @@ export interface RiveParameters {
8384
- `onStateChange?` - *(optional)* Callback that gets fired when a state change occurs.
8485
- `onAdvance?` - *(optional)* Callback that gets fired every frame when the Artboard has advanced.
8586
- `assetLoader?` - *(optional)* Callback that gets invoked for every asset detected in a Rive file (whether included or excluded). The callback is passed a reference to a Rive **FileAsset** and associated **bytes** for the file (if the asset is embedded in the file). In this callback, you'll determine whether or not to load the asset in your app yourself, or have Rive do it for you. For more details and examples, see the [Loading Assets](/runtimes/web/loading-assets) page.
87+
- `enablePerfMarks?` - *(optional)* Emits `performance.mark` / `performance.measure` entries for key Rive startup events. False by default. Also available on `RuntimeLoader` and `RiveFile`.
8688

8789
## APIs
8890

runtimes/web/web-js.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Follow the steps below to integrate Rive into your web app.
4545
// You can also pin to a specific version (See [here](https://www.npmjs.com/package/@rive-app/canvas) for the latest):
4646

4747

48-
<script src="https://unpkg.com/@rive-app/canvas@2.35.0"></script>
48+
<script src="https://unpkg.com/@rive-app/canvas@2.36.0"></script>
4949

5050
// This will make a global `rive` object available, allowing you to access the Rive API via the `rive` entry point:
5151

0 commit comments

Comments
 (0)