Skip to content

Commit 381bd05

Browse files
committed
[sorter] Release for #190 and #213
1 parent 50e2841 commit 381bd05

1 file changed

Lines changed: 48 additions & 8 deletions

File tree

site/guides/19_releases.md

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,47 @@ highlighted features.
55

66
---
77

8+
# v9.1
9+
10+
## Custom Sorting
11+
12+
This release adds custom sorting for sorted Row Id APIs, so applications can opt
13+
into numeric or domain-specific ordering without changing TinyBase's existing
14+
alphanumeric default behavior.
15+
16+
The getSortedRowIds method and addSortedRowIdsListener method now support a
17+
custom `sorter` function in the SortedRowIdsArgs object. The useSortedRowIds
18+
hook and getSortedRowIds Svelte function also accept the sorter positionally
19+
([#190](https://github.com/tinyplex/tinybase/issues/190),
20+
[#213](https://github.com/tinyplex/tinybase/issues/213)).
21+
22+
```js
23+
import {createStore as createStoreForNumericSort} from 'tinybase';
24+
25+
const numericSortStore = createStoreForNumericSort();
26+
['1', '10', '2'].forEach((rowId) =>
27+
numericSortStore.setRow('pets', rowId, {sold: false}),
28+
);
29+
const numericRowIdSorter = (sortKey1, sortKey2) =>
30+
Number(sortKey1) - Number(sortKey2);
31+
32+
console.log(
33+
numericSortStore.getSortedRowIds({
34+
tableId: 'pets',
35+
sorter: numericRowIdSorter,
36+
}),
37+
);
38+
// -> ['1', '2', '10']
39+
```
40+
41+
**Breaking change:** In the `ui-solid` and `ui-svelte` modules, the positional
42+
Store argument for `useSortedRowIds` and `getSortedRowIds` respectively has
43+
moved one slot later to make room for a positional custom sorter. If you pass a
44+
Store as the final positional argument, add `undefined` before it, or switch to
45+
the object argument form.
46+
47+
---
48+
849
# v9.0
950

1051
This release has no new features; just fixes and reliability improvements.
@@ -139,14 +180,13 @@ version after v9.0 has written to them.
139180

140181
Thanks to everyone whose reports and fixes shaped this release:
141182

142-
[Dheeraj](https://github.com/dheerajvs),
143-
[Jakub Riedl](https://github.com/jakubriedl),
144-
[Patryk Wegrzyn](https://github.com/patrykwegrzyn),
145-
[Damilola Romniyi](https://github.com/dsrominiyi),
146-
[Andrew Glago](https://github.com/a11rew),
147-
[wattroll](https://github.com/wattroll),
148-
[Will Honey](https://github.com/willhoney7), and
149-
[Daniel Berndt](https://github.com/danielberndt).
183+
[Dheeraj](https://github.com/dheerajvs), [Jakub
184+
Riedl](https://github.com/jakubriedl), [Patryk
185+
Wegrzyn](https://github.com/patrykwegrzyn), [Damilola
186+
Romniyi](https://github.com/dsrominiyi), [Andrew
187+
Glago](https://github.com/a11rew), [wattroll](https://github.com/wattroll),
188+
[Will Honey](https://github.com/willhoney7), and [Daniel
189+
Berndt](https://github.com/danielberndt).
150190

151191
Couldn't do it without you!
152192

0 commit comments

Comments
 (0)