Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(store): do not inject container state by default #2117

Merged
merged 1 commit into from
Mar 17, 2024

Conversation

arturovt
Copy link
Member

This commit updates the injectContainerState configuration property to default to false. This change will affect the behavior of @Selector()s, as they will no longer receive the container state as the first argument if there are any selectors in the list.

The current behavior is as follows:

@State()
class NotificationsState {
  @Selector()
  static getNotifications(state: NotificationsStateModel) {
    return state.notifications;
  }

  @Selector([NotificationsState.getNotifications])
  static getUnreadTotal(state: NotificationsStateModel, notifications: Notification[]) {
    return notifications.reduce(() => ..., 0);
  }
}

You might notice that the getUnreadTotal selector will have the notifications state injected as the first argument before accessing the notifications list.

This update has been made to prevent injecting the container state as the first argument if there are any selectors provided in the @Selector([...]) decorator. However, this change does not affect the @Selector() decorator with no arguments.

This commit updates the `injectContainerState` configuration property to default to false.
This change will affect the behavior of `@Selector()`s, as they will no longer receive the
container state as the first argument if there are any selectors in the list.

The current behavior is as follows:

```ts
@State()
class NotificationsState {
  @selector()
  static getNotifications(state: NotificationsStateModel) {
    return state.notifications;
  }

  @selector([NotificationsState.getNotifications])
  static getUnreadTotal(state: NotificationsStateModel, notifications: Notification[]) {
    return notifications.reduce(() => ..., 0);
  }
}
```

You might notice that the `getUnreadTotal` selector will have the notifications state injected
as the first argument before accessing the notifications list.

This update has been made to prevent injecting the container state as the first argument if
there are any selectors provided in the `@Selector([...])` decorator. However, this change does
not affect the `@Selector()` decorator with no arguments.
Copy link

nx-cloud bot commented Mar 17, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 7f257b3. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 6 targets

Sent with 💌 from NxCloud.

Copy link

bundlemon bot commented Mar 17, 2024

BundleMon (Integration Projects)

Unchanged files (2)
Status Path Size Limits
Main bundles(Gzip)
hello-world-ng17/dist-integration/main.(hash)
.js
68.48KB +1%
Main bundles(Gzip)
hello-world-ng16/dist-integration/main.(hash)
.js
66.98KB +1%

Total files change -15B -0.01%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

Copy link

codeclimate bot commented Mar 17, 2024

Code Climate has analyzed commit 7f257b3 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 95.3% (-0.1% change).

View more on Code Climate.

@arturovt arturovt marked this pull request as ready for review March 17, 2024 19:32
@arturovt arturovt merged commit 62f80d5 into master Mar 17, 2024
12 checks passed
@arturovt arturovt deleted the fix/inject-container branch March 17, 2024 19:32
@markwhitfeld markwhitfeld added this to the v.18.0.0 milestone Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants