Skip to content
This repository was archived by the owner on Feb 15, 2025. It is now read-only.

Commit 0ec9c73

Browse files
committed
completed rough collection method docs
1 parent 6b49b21 commit 0ec9c73

File tree

1 file changed

+115
-5
lines changed

1 file changed

+115
-5
lines changed

docs/packages/core/features/collection/Methods.md

Lines changed: 115 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,22 +1312,24 @@ Array<number | string>
13121312
With `remove()` we are able to remove Item/s from
13131313

13141314
- ### `everywhere()`
1315-
Removes the Item/s at `itemKey/s` from the entire Collection and all [Groups](./group/Introduction.md) / [Selectors](./selector/Introduction.md),
1315+
Removes Item/s at `itemKey/s` from the entire Collection and all [Groups](./group/Introduction.md) / [Selectors](./selector/Introduction.md),
13161316
i.e. from everywhere.
13171317
```ts
13181318
MY_COLLECTION.remove('item1').everywhere();
13191319
```
1320+
Synonym to [`removeItems()`](#removeitems).
13201321

13211322
- ### `fromGroups()`
1322-
Removes the Item/s at `itemKey/s` only from specific [Groups](./group/Introduction.md).
1323+
Removes Item/s at `itemKey/s` only from specific [Groups](./group/Introduction.md).
13231324
```ts
13241325
MY_COLLECTION.remove('item1').fromGroups(['group1', 'group2']);
13251326
```
1327+
Synonym to [`removeFromGroups()`](#removefromgroups).
13261328

13271329
:::info
13281330

13291331
Note that a standalone `remove()` doesn't do anything,
1330-
so we have to always add `.everywhere()` or `.fromGroups()`.
1332+
so we must always add `.everywhere()` or `.fromGroups()`.
13311333

13321334
:::
13331335

@@ -1358,7 +1360,7 @@ so we have to always add `.everywhere()` or `.fromGroups()`.
13581360

13591361
## `removeFromGroups()`
13601362

1361-
Removes Item at `itemKey` from specific [Group](./group/Introduction.md).
1363+
Removes Item at `itemKey` from specific [Group](./group/Introduction.md) at `groupKey`.
13621364
```ts
13631365
MY_COLLECTION.removeFromGroups('item1', 'group1');
13641366
```
@@ -1372,7 +1374,8 @@ In the above example the Items at `item1` and `item2` will be removed from the G
13721374

13731375
| Prop | Type | Default | Description | Required |
13741376
|----------------------|-----------------------------------------------------------------------------------|------------|-----------------------------------------------------------------------------------------------|----------|
1375-
| `itemKeys` | number \| string | Array<number \| string\> | undefined | itemKey/s that get removed | Yes |
1377+
| `itemKeys` | number \| string | Array<number \| string\> | undefined | itemKey/s of Items that that get removed from Group/s | Yes |
1378+
| `groupKeys` | number \| string | Array<number \| string\> | undefined | groupKey/s of Group/s from which the Item/s will be removed | Yes |
13761379

13771380
### 📄 Return
13781381

@@ -1381,3 +1384,110 @@ Collection
13811384
```
13821385
Returns the [Collection](./Introduction.md) it was called on.
13831386

1387+
1388+
1389+
<br />
1390+
1391+
---
1392+
1393+
<br />
1394+
1395+
1396+
1397+
## `removeItems()`
1398+
1399+
Removes Item at `itemKey` from the entire Collection and all [Groups](./group/Introduction.md) / [Selectors](./selector/Introduction.md)
1400+
```ts
1401+
MY_COLLECTION.removeItems('item1');
1402+
```
1403+
It is also possible to remove multiple Items at once.
1404+
```ts
1405+
MY_COLLECTION.removeItems(['item1', 'item2']);
1406+
```
1407+
1408+
### ⚠️ Remove includes?
1409+
1410+
- remove Item/s from the entire Collection
1411+
- remove Item/s from all Groups
1412+
- remove Item/s from all Selectors
1413+
- remove Item value/s from Storage
1414+
1415+
### 📭 Props
1416+
1417+
| Prop | Type | Default | Description | Required |
1418+
|----------------------|-----------------------------------------------------------------------------------|------------|-----------------------------------------------------------------------------------------------|----------|
1419+
| `itemKeys` | number \| string | Array<number \| string\> | undefined | itemKey/s of Item/s that get removed | Yes |
1420+
1421+
### 📄 Return
1422+
1423+
```ts
1424+
Collection
1425+
```
1426+
Returns the [Collection](./Introduction.md) it was called on.
1427+
1428+
1429+
1430+
<br />
1431+
1432+
---
1433+
1434+
<br />
1435+
1436+
1437+
1438+
## `setData()`
1439+
1440+
:::warning
1441+
1442+
**No public function!** (only public for testing purpose) <br/>
1443+
`setData()` applies newly set data (for instance from the [`collect()`](#collect) method) to the Collection.
1444+
1445+
:::
1446+
1447+
1448+
1449+
<br />
1450+
1451+
---
1452+
1453+
<br />
1454+
1455+
1456+
1457+
## `rebuildGroupsThatIncludeItemKey()`
1458+
1459+
:::warning
1460+
1461+
This function is mainly thought for the internal use.
1462+
1463+
:::
1464+
1465+
Rebuilds all [Groups](./group/Introduction.md) that include the provided `itemKey`.
1466+
```ts
1467+
MY_COLLECTION.rebuildGroupsThatIncludeItemKey('item1');
1468+
```
1469+
Such rebuild does recompute the `output` of the Group.
1470+
```ts
1471+
// group value '[1, 2, 3]'
1472+
// group output '[{id: 1, name: 'jeff'}, {id: 3, name: 'hans'}]'
1473+
1474+
// Item gets added to Collection -> Collection rebuilds all Groups that include the 'itemKey'
1475+
MY_COLLECTION.collect({id: 2, name: 'jeff'});
1476+
// Exectues internally: 'MY_COLLECTION.rebuildGroupsThatIncludeItemKey(2)'
1477+
1478+
// group output '[{id: 1, name: 'jeff'}, {id: 2, name: 'jeff'}, {id: 3, name: 'hans'}]'
1479+
```
1480+
1481+
### 📭 Props
1482+
1483+
| Prop | Type | Default | Description | Required |
1484+
|----------------------|-----------------------------------------------------------------------------------|------------|-----------------------------------------------------------------------------------------------|----------|
1485+
| `itemKey` | number \| string | undefined | itemKey | Yes |
1486+
| `config` | RebuildGroupsThatIncludeItemKeyConfigInterface | {} | Configuration | No |
1487+
1488+
### 📄 Return
1489+
1490+
```ts
1491+
Collection
1492+
```
1493+
Returns the [Collection](./Introduction.md) it was called on.

0 commit comments

Comments
 (0)