Skip to content

Commit

Permalink
feat(core): add blocking wait_for_event_handlers method to Store
Browse files Browse the repository at this point in the history
…to wait for all event handlers to finish
  • Loading branch information
sassanh committed Aug 15, 2024
1 parent ee18a30 commit 616dfc2
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 131 deletions.
136 changes: 45 additions & 91 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
# Changelog

## Version 0.16.0

- feat(core): add blocking `wait_for_event_handlers` method to `Store` to wait for all event handlers to finish

## Version 0.15.10

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

## Version 0.15.9

- refactor(core): use `str_to_bool` of `python-strtobool` instead of `strtobool`
of `distutils`
- refactor(core): use `str_to_bool` of `python-strtobool` instead of `strtobool` of `distutils`
- feat(test-snapshot): add prefix to snapshot fixture

## Version 0.15.8

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

## Version 0.15.7

- 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()`
- 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()`

## Version 0.15.5

- 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)
- 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.
- 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)
- 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.

## Version 0.15.4

Expand All @@ -40,29 +36,20 @@

## Version 0.15.2

- refactor(autorun): improve type-hints so that its final return value has the correct
type, regardless `default_value` is provided or not
- refactor(view): improve type-hints so that its final return value has the correct
type, regardless `default_value` is provided or not
- refactor(autorun): improve type-hints so that its final return value has the correct type, regardless `default_value` is provided or not
- refactor(view): improve type-hints so that its final return value has the correct type, regardless `default_value` is provided or not
- refactor(combine_reducers): use `make_immutable` instead of `make_dataclass`
- test(view): write tests for `store.view`

## Version 0.15.1

- 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
- 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
- feat(test): add performance tests to check it doesn't timeout in edge cases

## Version 0.15.0

- 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
- 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.
- 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
- 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.

## Version 0.14.5

Expand All @@ -82,23 +69,17 @@

## Version 0.14.1

- 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`
- 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`

## Version 0.14.0

- refactor: `Store` no longer aggregates changes, it now calls listeners with every
change
- 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)
- refactor(test): `event_loop` fixture now sets the global event loop on setup and
restores it on teardown
- refactor: `Store` no longer aggregates changes, it now calls listeners with every change
- 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)
- refactor(test): `event_loop` fixture now sets the global event loop on setup and restores it on teardown

## Version 0.13.2

- fix: initial snapshot cleanup which used to mistakenly remove files with store:...
filenames now removes files with store-... filenames
- fix: initial snapshot cleanup which used to mistakenly remove files with store:... filenames now removes files with store-... filenames

## Version 0.13.1

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

## Version 0.12.7

Expand All @@ -127,26 +106,21 @@

## Version 0.12.5

- refactor: add cleanup to `FinishEvent` handler to clean workers, listeners, subscriptions,
autoruns, etc
- refactor: add cleanup to `FinishEvent` handler to clean workers, listeners, subscriptions, autoruns, etc
- refactor: `TaskCreator` add `TaskCreatorCallback` protocols
- refactor: `Store._create_task` now has a callback parameter to report the created
task
- refactor: move serialization methods and side_effect_runner class to separate
files
- refactor: `Store._create_task` now has a callback parameter to report the created task
- refactor: move serialization methods and side_effect_runner class to separate files

## Version 0.12.4

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

## Version 0.12.3

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

Expand All @@ -162,16 +136,14 @@

## Version 0.12.0

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

## Version 0.11.0

- 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
- 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
- refacotr: general housekeeping

## Version 0.10.7
Expand All @@ -195,8 +167,7 @@

## Version 0.10.0

- refactor: remove `create_store` closure in favor of `Store` class with identical
api
- refactor: remove `create_store` closure in favor of `Store` class with identical api

## Version 0.9.25

Expand All @@ -208,25 +179,21 @@

## Version 0.9.23

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

## Version 0.9.22

- fix: `CombineReducerRegisterAction` should take care of `CompleteReducerResult`
returned by the sub-reducer on its initialization.
- fix: `CombineReducerRegisterAction` should take care of `CompleteReducerResult` returned by the sub-reducer on its initialization.

## Version 0.9.21

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

## Version 0.9.20

- refactor: encapsulate autorun options previously provided as multiple keyword arguments,
in a single `AutorunOptions` immutable class
- refactor: encapsulate autorun options previously provided as multiple keyword arguments, in a single `AutorunOptions` immutable class
- refactor: rename `immediate` to `immediate_run` in autorun subscribers
- 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
- 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

## Version 0.9.19

Expand All @@ -239,8 +206,7 @@

## Version 0.9.17

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

## Version 0.9.15

Expand All @@ -252,18 +218,15 @@

## Version 0.9.13

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

## Version 0.9.12

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

## Version 0.9.11

- 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`
- 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`

## Version 0.9.10

Expand All @@ -272,8 +235,7 @@

## Version 0.9.9

- refactor: improve typehints and allow dispatch to get multiple actions/events
via `*args`
- refactor: improve typehints and allow dispatch to get multiple actions/events via `*args`

## Version 0.9.8

Expand All @@ -298,13 +260,11 @@

## Version 0.9.3

- refactor: add `subscribe` property to the type of the return value of an
autorun decorator
- refactor: add `subscribe` property to the type of the return value of an autorun decorator

## Version 0.9.2

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

## Version 0.9.1

Expand All @@ -313,8 +273,7 @@
## Version 0.9.0

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

Expand All @@ -328,13 +287,11 @@

## Version 0.8.0

- feat: drop `type` field in actions and events altogether, recognition is done
by `isinstance`
- feat: drop `type` field in actions and events altogether, recognition is done by `isinstance`

## Version 0.7.3

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

## Version 0.7.2

Expand All @@ -350,8 +307,7 @@

## Version 0.6.3

- fix: let input reducers of `combine_reducers` have arbitrary action types
irrelevant to each other
- fix: let input reducers of `combine_reducers` have arbitrary action types irrelevant to each other

## Version 0.6.2

Expand All @@ -368,12 +324,10 @@

## Version 0.5.0

- feat: introduce `immutable` decorator as a shortcut of
`dataclass(kw_only=True, frozen=True)`
- feat: introduce `immutable` decorator as a shortcut of `dataclass(kw_only=True, frozen=True)`
- feat: introduce `Immutable` class, its subclasses automatically become `immutable`
- refactor: `BaseAction` now inherits from `Immutable`
- refactor: Removed `BaseState`, state classes, payload classes, etc should now
inherit `Immutable`
- refactor: Removed `BaseState`, state classes, payload classes, etc should now inherit `Immutable`

## Version 0.4.0

Expand Down
Loading

0 comments on commit 616dfc2

Please sign in to comment.