Skip to content

Commit c1a1c18

Browse files
committed
Reset decay on data set
1 parent 5434c03 commit c1a1c18

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

docs/docs/api-reference/CollectionData.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ A piece of data belonging to a collection
1616
* [.patch(value)](#CollectionData+patch) ⇒ <code>this</code>
1717
* [.delete()](#CollectionData+delete) ⇒ <code>this</code>
1818
* [.clean()](#CollectionData+clean) ⇒ <code>this</code>
19+
* [.decay(time)](#CollectionData+decay) ⇒ <code>this</code>
1920

2021
<a name="CollectionData+id"></a>
2122

@@ -71,3 +72,14 @@ A piece of data belonging to a collection
7172
<p>Clean this data instance (remove all watchers &amp; remove the state from the instance)</p>
7273

7374
**Returns**: <code>this</code> <p>The data instance</p>
75+
<a name="CollectionData+decay"></a>
76+
77+
### .decay(time) ⇒ <code>this</code>
78+
<p>Decay this data instance after a certain amount of time</p>
79+
80+
**Returns**: <code>this</code> <p>The data instance</p>
81+
82+
| Param | Type | Description |
83+
| --- | --- | --- |
84+
| time | <code>boolean</code> \| <code>string</code> | <p>The time to decay in ms</p> |
85+

packages/plexus-core/src/collection/data.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,10 @@ export class CollectionData<
305305
)
306306
}
307307
this.collection().lastUpdatedKey = this.key
308-
308+
const decayRate = this.collection().config.decay
309+
if (decayRate) {
310+
this.decay(decayRate)
311+
}
309312
return this
310313
}
311314
/**

0 commit comments

Comments
 (0)