Skip to content

Commit 2a0c107

Browse files
committed
feat: add immediate parameter to subscribe method of autorun's returned value
1 parent bd22df7 commit 2a0c107

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

CHANGELOG.md

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

3+
## Version 0.9.19
4+
5+
- feat: add `immediate` parameter to `subscribe` method of `autorun`'s returned value
6+
37
## Version 0.9.18
48

59
- feat: `autorun` decorator accepts a default value for when store is not initialized

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "python-redux"
3-
version = "0.9.18"
3+
version = "0.9.19"
44
description = "Redux implementation for Python"
55
authors = ["Sassan Haradji <sassanh@gmail.com>"]
66
license = "Apache-2.0"

redux/basic_types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ def value(self: AutorunReturnType) -> AutorunOriginalReturnType:
121121
def subscribe(
122122
self: AutorunReturnType,
123123
callback: Callable[[AutorunOriginalReturnType], Any],
124+
*,
125+
immediate: bool = False,
124126
) -> Callable[[], None]:
125127
...
126128

redux/main.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,13 @@ def value(self: Call) -> AutorunOriginalReturnType:
233233
def subscribe(
234234
self: Call,
235235
callback: Callable[[AutorunOriginalReturnType], Any],
236+
*,
237+
immediate: bool = False,
236238
) -> Callable[[], None]:
237239
subscriptions.append(callback)
238-
callback(self.value)
240+
241+
if immediate:
242+
callback(self.value)
239243

240244
def unsubscribe() -> None:
241245
subscriptions.remove(callback)

0 commit comments

Comments
 (0)