Skip to content

Commit 616dfc2

Browse files
committed
feat(core): add blocking wait_for_event_handlers method to Store to wait for all event handlers to finish
1 parent ee18a30 commit 616dfc2

File tree

6 files changed

+88
-131
lines changed

6 files changed

+88
-131
lines changed

CHANGELOG.md

Lines changed: 45 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
11
# Changelog
22

3+
## Version 0.16.0
4+
5+
- feat(core): add blocking `wait_for_event_handlers` method to `Store` to wait for all event handlers to finish
6+
37
## Version 0.15.10
48

59
- feat(test): add arguments for `wait_for`'s `check`
610

711
## Version 0.15.9
812

9-
- refactor(core): use `str_to_bool` of `python-strtobool` instead of `strtobool`
10-
of `distutils`
13+
- refactor(core): use `str_to_bool` of `python-strtobool` instead of `strtobool` of `distutils`
1114
- feat(test-snapshot): add prefix to snapshot fixture
1215

1316
## Version 0.15.8
1417

15-
- feat(test-snapshot): the `selector` function can signal the `monitor` it should
16-
ignore a particular snapshot of the state by returning `None`
18+
- feat(test-snapshot): the `selector` function can signal the `monitor` it should ignore a particular snapshot of the state by returning `None`
1719

1820
## Version 0.15.7
1921

20-
- refactor(test-snapshot): make it aligned with `pyfakefs` by using `try`/`except`
21-
instead of checking `Path().exists()` as `pyfakefs` doesn't seem to respect `skip_names`
22-
for `Path().exists()`
22+
- refactor(test-snapshot): make it aligned with `pyfakefs` by using `try`/`except` instead of checking `Path().exists()` as `pyfakefs` doesn't seem to respect `skip_names` for `Path().exists()`
2323

2424
## Version 0.15.5
2525

26-
- feat(test-snapshot): while still taking snapshots of the whole state of the
27-
store, one can narrow this down by providing a selector to the `snapshot` method
28-
(used to be a property)
29-
- feat(test-snapshot): new `monitor` method to let a test automatically take snapshots
30-
of the store whenever it is changed. Takes an optional selector to narrow down
31-
the snapshot.
26+
- feat(test-snapshot): while still taking snapshots of the whole state of the store, one can narrow this down by providing a selector to the `snapshot` method (used to be a property)
27+
- feat(test-snapshot): new `monitor` method to let a test automatically take snapshots of the store whenever it is changed. Takes an optional selector to narrow down the snapshot.
3228

3329
## Version 0.15.4
3430

@@ -40,29 +36,20 @@
4036

4137
## Version 0.15.2
4238

43-
- refactor(autorun): improve type-hints so that its final return value has the correct
44-
type, regardless `default_value` is provided or not
45-
- refactor(view): improve type-hints so that its final return value has the correct
46-
type, regardless `default_value` is provided or not
39+
- refactor(autorun): improve type-hints so that its final return value has the correct type, regardless `default_value` is provided or not
40+
- refactor(view): improve type-hints so that its final return value has the correct type, regardless `default_value` is provided or not
4741
- refactor(combine_reducers): use `make_immutable` instead of `make_dataclass`
4842
- test(view): write tests for `store.view`
4943

5044
## Version 0.15.1
5145

52-
- feat(core): add `view` method to `Store` to allow computing a derived value from
53-
the state only when it is accessed and caching the result until the relevant parts
54-
of the state change
46+
- feat(core): add `view` method to `Store` to allow computing a derived value from the state only when it is accessed and caching the result until the relevant parts of the state change
5547
- feat(test): add performance tests to check it doesn't timeout in edge cases
5648

5749
## Version 0.15.0
5850

59-
- refactor(autorun)!: setting `initial_run` option of autorun to `False` used to
60-
make the autorun simply not call the function on initialization, now it makes
61-
sure the function is not called until the selector's value actually changes
62-
- feat(autorun): add `auto_call` and `reactive` options to autorun to control whether
63-
the autorun should call the function automatically when the comparator's value
64-
changes and whether it shouldn't automatically call it but yet register a change
65-
so that when it is manually called the next time, it will call the function.
51+
- refactor(autorun)!: setting `initial_run` option of autorun to `False` used to make the autorun simply not call the function on initialization, now it makes sure the function is not called until the selector's value actually changes
52+
- feat(autorun): add `auto_call` and `reactive` options to autorun to control whether the autorun should call the function automatically when the comparator's value changes and whether it shouldn't automatically call it but yet register a change so that when it is manually called the next time, it will call the function.
6653

6754
## Version 0.14.5
6855

@@ -82,23 +69,17 @@
8269

8370
## Version 0.14.1
8471

85-
- feat: introduce `grace_time_in_seconds` parameter to `Store` to allow a grace
86-
period for the store to finish its work before calling `cleanup` and `on_finish`
72+
- feat: introduce `grace_time_in_seconds` parameter to `Store` to allow a grace period for the store to finish its work before calling `cleanup` and `on_finish`
8773

8874
## Version 0.14.0
8975

90-
- refactor: `Store` no longer aggregates changes, it now calls listeners with every
91-
change
92-
- refactor: `SideEffectRunnerThread` now runs async side effects in the event loop
93-
of the thread in which it was instantiated in (it used to create its own event
94-
loop)
95-
- refactor(test): `event_loop` fixture now sets the global event loop on setup and
96-
restores it on teardown
76+
- refactor: `Store` no longer aggregates changes, it now calls listeners with every change
77+
- refactor: `SideEffectRunnerThread` now runs async side effects in the event loop of the thread in which it was instantiated in (it used to create its own event loop)
78+
- refactor(test): `event_loop` fixture now sets the global event loop on setup and restores it on teardown
9779

9880
## Version 0.13.2
9981

100-
- fix: initial snapshot cleanup which used to mistakenly remove files with store:...
101-
filenames now removes files with store-... filenames
82+
- fix: initial snapshot cleanup which used to mistakenly remove files with store:... filenames now removes files with store-... filenames
10283

10384
## Version 0.13.1
10485

@@ -111,10 +92,8 @@
11192
- test: add tests for scheduler and fixtures
11293
- refactor: `SideEffectRunnerThread` now runs async side effects in its own event-loop
11394
- refactor: removed `immediate_run` from event subscriptions
114-
- refactor: removed `EventSubscriptionOptions` as the only option left was `keep_ref`,
115-
it's now a parameter of `subscribe_event`
116-
- feat: new `on_finish` callback for the store, it runs when all worker threads are
117-
joined and resources are freed
95+
- refactor: removed `EventSubscriptionOptions` as the only option left was `keep_ref`, it's now a parameter of `subscribe_event`
96+
- feat: new `on_finish` callback for the store, it runs when all worker threads are joined and resources are freed
11897

11998
## Version 0.12.7
12099

@@ -127,26 +106,21 @@
127106

128107
## Version 0.12.5
129108

130-
- refactor: add cleanup to `FinishEvent` handler to clean workers, listeners, subscriptions,
131-
autoruns, etc
109+
- refactor: add cleanup to `FinishEvent` handler to clean workers, listeners, subscriptions, autoruns, etc
132110
- refactor: `TaskCreator` add `TaskCreatorCallback` protocols
133-
- refactor: `Store._create_task` now has a callback parameter to report the created
134-
task
135-
- refactor: move serialization methods and side_effect_runner class to separate
136-
files
111+
- refactor: `Store._create_task` now has a callback parameter to report the created task
112+
- refactor: move serialization methods and side_effect_runner class to separate files
137113

138114
## Version 0.12.4
139115

140-
- fix: serialization class methods of `Store` use `cls` instead of `Store` for the
141-
sake of extensibility via inheritance
116+
- fix: serialization class methods of `Store` use `cls` instead of `Store` for the sake of extensibility via inheritance
142117
- refactor: `pytest_addoption` moved to `test.py` to make reusable
143118

144119
## Version 0.12.3
145120

146121
- test: write tests for different features of the api
147122
- refactor: rename certain names in the api to better reflect their job
148-
- refactor: store_snapshot now puts snapshot files in a hierarchical directory structure
149-
based on the test module and test name
123+
- refactor: store_snapshot now puts snapshot files in a hierarchical directory structure based on the test module and test name
150124
- fix: sort JSON keys in `snapshot_store`'s `json_snapshot`
151125
- test: cover most features with tests
152126

@@ -162,16 +136,14 @@
162136

163137
## Version 0.12.0
164138

165-
- refactor: improve creating new state classes in `combine_reducers` upon registering/unregistering
166-
sub-reducers
139+
- refactor: improve creating new state classes in `combine_reducers` upon registering/unregistering sub-reducers
167140
- feat: add test fixture for snapshot testing the store
168141
- chore(test): add test infrastructure for snapshot testing the store
169142
- test: move demo files to test files and update the to use snapshot fixture
170143

171144
## Version 0.11.0
172145

173-
- feat: add `keep_ref` parameter to subscriptions and autoruns, defaulting to `True`,
174-
if set to `False`, the subscription/autorun will not keep a reference to the callback
146+
- feat: add `keep_ref` parameter to subscriptions and autoruns, defaulting to `True`, if set to `False`, the subscription/autorun will not keep a reference to the callback
175147
- refacotr: general housekeeping
176148

177149
## Version 0.10.7
@@ -195,8 +167,7 @@
195167

196168
## Version 0.10.0
197169

198-
- refactor: remove `create_store` closure in favor of `Store` class with identical
199-
api
170+
- refactor: remove `create_store` closure in favor of `Store` class with identical api
200171

201172
## Version 0.9.25
202173

@@ -208,25 +179,21 @@
208179

209180
## Version 0.9.23
210181

211-
- feat(combine_reducers): initialization of sub-reducers is done with `CombineReducerInitAction`
212-
containing `_id` instead of normal `InitAction`
182+
- feat(combine_reducers): initialization of sub-reducers is done with `CombineReducerInitAction` containing `_id` instead of normal `InitAction`
213183

214184
## Version 0.9.22
215185

216-
- fix: `CombineReducerRegisterAction` should take care of `CompleteReducerResult`
217-
returned by the sub-reducer on its initialization.
186+
- fix: `CombineReducerRegisterAction` should take care of `CompleteReducerResult` returned by the sub-reducer on its initialization.
218187

219188
## Version 0.9.21
220189

221190
- feat: new option for all subscriptions to hint them keep a weakref of the callback
222191

223192
## Version 0.9.20
224193

225-
- refactor: encapsulate autorun options previously provided as multiple keyword arguments,
226-
in a single `AutorunOptions` immutable class
194+
- refactor: encapsulate autorun options previously provided as multiple keyword arguments, in a single `AutorunOptions` immutable class
227195
- refactor: rename `immediate` to `immediate_run` in autorun subscribers
228-
- feat: default value of `immediate_run` can be set for all subscribers of an autorun
229-
instance by settings `subscribers_immediate_run` option for the autorun
196+
- feat: default value of `immediate_run` can be set for all subscribers of an autorun instance by settings `subscribers_immediate_run` option for the autorun
230197

231198
## Version 0.9.19
232199

@@ -239,8 +206,7 @@
239206

240207
## Version 0.9.17
241208

242-
- refactor: make `dispatch` accept a `with_state(store)` function as parameter, if
243-
provided it will dispatch return value of this function
209+
- refactor: make `dispatch` accept a `with_state(store)` function as parameter, if provided it will dispatch return value of this function
244210

245211
## Version 0.9.15
246212

@@ -252,18 +218,15 @@
252218

253219
## Version 0.9.13
254220

255-
- feat: make `subscribe` method of `autorun`'s return value, call its callback with
256-
the latest value immediately
221+
- feat: make `subscribe` method of `autorun`'s return value, call its callback with the latest value immediately
257222

258223
## Version 0.9.12
259224

260225
- feat: add the latest value of `autorun` to the `value` field of its returned value
261226

262227
## Version 0.9.11
263228

264-
- feat: the provided `scheduler`, if any, should have a `interval` parameter, if
265-
set to `False`, it should schedule only once, otherwise it should periodically
266-
call the `callback`
229+
- feat: the provided `scheduler`, if any, should have a `interval` parameter, if set to `False`, it should schedule only once, otherwise it should periodically call the `callback`
267230

268231
## Version 0.9.10
269232

@@ -272,8 +235,7 @@
272235

273236
## Version 0.9.9
274237

275-
- refactor: improve typehints and allow dispatch to get multiple actions/events
276-
via `*args`
238+
- refactor: improve typehints and allow dispatch to get multiple actions/events via `*args`
277239

278240
## Version 0.9.8
279241

@@ -298,13 +260,11 @@
298260

299261
## Version 0.9.3
300262

301-
- refactor: add `subscribe` property to the type of the return value of an
302-
autorun decorator
263+
- refactor: add `subscribe` property to the type of the return value of an autorun decorator
303264

304265
## Version 0.9.2
305266

306-
- refactor: use `Immutable` from python-immutable package (extracted and created
307-
based on `Immutable` class of this package)
267+
- refactor: use `Immutable` from python-immutable package (extracted and created based on `Immutable` class of this package)
308268

309269
## Version 0.9.1
310270

@@ -313,8 +273,7 @@
313273
## Version 0.9.0
314274

315275
- feat: add `scheduler` option to schedule running actions in the main loop of frameworks
316-
- feat: add `threads` option to run event handlers asynchronous in `threads`
317-
number of threads
276+
- feat: add `threads` option to run event handlers asynchronous in `threads` number of threads
318277
- refacotr: allow `Any` return type for event handler and subscriber functions
319278
- feat: add `subscribe` property to the returned function of `autorun`
320279

@@ -328,13 +287,11 @@
328287

329288
## Version 0.8.0
330289

331-
- feat: drop `type` field in actions and events altogether, recognition is done
332-
by `isinstance`
290+
- feat: drop `type` field in actions and events altogether, recognition is done by `isinstance`
333291

334292
## Version 0.7.3
335293

336-
- fix: loosen `subscribe_event` typing constraints as python doesn't have enough
337-
type narrowing mechanism at the moment
294+
- fix: loosen `subscribe_event` typing constraints as python doesn't have enough type narrowing mechanism at the moment
338295

339296
## Version 0.7.2
340297

@@ -350,8 +307,7 @@
350307

351308
## Version 0.6.3
352309

353-
- fix: let input reducers of `combine_reducers` have arbitrary action types
354-
irrelevant to each other
310+
- fix: let input reducers of `combine_reducers` have arbitrary action types irrelevant to each other
355311

356312
## Version 0.6.2
357313

@@ -368,12 +324,10 @@
368324

369325
## Version 0.5.0
370326

371-
- feat: introduce `immutable` decorator as a shortcut of
372-
`dataclass(kw_only=True, frozen=True)`
327+
- feat: introduce `immutable` decorator as a shortcut of `dataclass(kw_only=True, frozen=True)`
373328
- feat: introduce `Immutable` class, its subclasses automatically become `immutable`
374329
- refactor: `BaseAction` now inherits from `Immutable`
375-
- refactor: Removed `BaseState`, state classes, payload classes, etc should now
376-
inherit `Immutable`
330+
- refactor: Removed `BaseState`, state classes, payload classes, etc should now inherit `Immutable`
377331

378332
## Version 0.4.0
379333

0 commit comments

Comments
 (0)