Skip to content

Initial actions#3624

Closed
stephencelis wants to merge 6 commits intomainfrom
initial-actions
Closed

Initial actions#3624
stephencelis wants to merge 6 commits intomainfrom
initial-actions

Conversation

@stephencelis
Copy link
Copy Markdown
Member

It is common to send an action to a store when it is first created to kick off some long-living effects. While many utilize the onAppear view modifier for this work, we can simplify things by making the store's initializer a little more powerful.

It is common to send an action to a store when it is first created to
kick off some long-living effects. While many utilize the `onAppear`
view modifier for this work, we can simplify things by making the
store's initializer a little more powerful.
@stephencelis stephencelis requested a review from mbrandonw March 14, 2025 19:19
reducer: reducer.dependency(\.self, dependencies)
)
if let initialAction = initialAction() {
send(initialAction)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we send initial actions to stores created by store.scope(…)?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. It's rather uncommon outside of tests to use the store's initialiser directly.

@arnauddorgans arnauddorgans mentioned this pull request Jan 8, 2026
@stephencelis
Copy link
Copy Markdown
Member Author

Closing in favor of bigger plans in TCA 2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants