Skip to content

Commit 41de449

Browse files
authored
Merge pull request #90 from latentflip/integrate-bundles-overwrite
- allow missing selectors in subscribeToSelectors with allowMissing option - fix `init` being called too early when using `integrateBundles` - docs updates - switch to github actions for CI
2 parents 6d7901f + 4647cc8 commit 41de449

File tree

10 files changed

+826
-161
lines changed

10 files changed

+826
-161
lines changed

.circleci/config.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/ci.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 18
23+
cache: 'npm'
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Build and test
29+
run: npm run build && npm test

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ Created for and used by PWAs that value small bundle sizes, network resilience,
66

77
If you pair it with [Preact](https://preactjs.com/) it's ~15kb for an entire app toolkit.
88

9-
If you want to see an app built with it, check out: [anesthesiacharting.com](https://anesthesiacharting.com).
9+
If you want to see an app built with it, check out: [xchart.com](https://xchart.com).
1010

1111
See docs site here: https://reduxbundler.com

docs/api/store.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@ Shortcut for calling `store.select()` but passing in all known selector names.
3333

3434
Add additional bundles after the fact. This will manage updating redux-bundler and internally using redux's `.replaceReducer` to update the store in place.
3535

36-
## `store.subscribeToSelectors(arrayOfSelectors, callback)`
36+
Any `init` methods on the bundles will be called after the store is configured.
3737

38-
Given an array of selector names, the callback will be called whenever the resulting values change.
38+
## `store.subscribeToSelectors(arrayOfSelectors, callback, [options])`
39+
40+
Given an array of selector names, the callback will be called whenever the resulting values change. This will _not_ be called with the initial value/state of the selector.
41+
42+
Passing `{ allowMissing: true }` as `options` will let you pass selectors that don't yet exist on the store without throwing an error. This may be helpful if
43+
a bundle that gets integrated later via `integrateBundle` will add a selector that you want to listen for. If the initial value of the selector when the new bundle is integrated is anything but `undefined` the callback will be fired with the initial value.
3944

4045
Just like Redux's `subscribe()` it returns a function that can be used to unsubscribe.
4146

docs/misc/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
- `29.0.0` This release has some changes that are unlikely to be breaking, but for safety releasing as a major bump:
4+
- Fixes a bug during `integrateBundles` calls where the new bundles' `init` functions would be called before the store reducer had been replaced; potentially causing the code in the `init` function to throw if it called a selector that depended on the new state. The `init` functions are now called as the final step in `integrateBundles` - this is unlikely to be a breaking but if you are using `integrateBundles` and `init` functions, verifying they are working as expected is advised.
5+
- Adds an `allowMissing` option to `subsribeToSelectors`. If passed, you can now subscribe to selectors that don't yet exist without the `subscribeToSelectors` call throwing. If the selector is added later (via `integrateBundles`) then changes to that selector will be emitted to the callback as expected.
6+
- Switched CI from circle ci to github actions
37
- `28.1.0` Minor non-breaking enhancement to `createRouteBundle` to more easily allow dynamic replacement of routes. Adding `doReplaceRoutes` action creator and explicitly storing cached routes and routeMatcher in a reducer so they can be easily replaced.
48
- `28.0.3` No API changes.
59
- Replaces all uses of `self` with `globalThis`.

0 commit comments

Comments
 (0)