ngxs / store

🚀 NGXS - State Management for Angular
http://ngxs.io
MIT License
3.54k stars 405 forks source link

fix(store): run plugins in injection context #2256

Closed arturovt closed 1 week ago

arturovt commented 1 week ago

In this commit, we enable plugin functions to run within the injection context. This allows plugin functions (but not classes) to call inject and access dependencies.

Additionally, we've moved compose to the Dispatcher class since it was only used once. Keeping it in the Dispatcher ensures it isn't used elsewhere and can be safely inlined if needed.

nx-cloud[bot] commented 1 week ago

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 4c36c5c5b8e4fd87b512f2dbaf554cccb6e656f7. 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 4 targets - [`nx run-many --target=test --all --configuration=ci --maxWorkers=4`](https://cloud.nx.app/runs/mLzp8JuNU9?utm_source=pull-request&utm_medium=comment) - [`nx lint-types store`](https://cloud.nx.app/runs/0AQQAU1D5Y?utm_source=pull-request&utm_medium=comment) - [`nx run-many --target=lint --all --exclude=create-app`](https://cloud.nx.app/runs/05nhkPKPdc?utm_source=pull-request&utm_medium=comment) - [`nx run-many --target=build --all`](https://cloud.nx.app/runs/VXc1pIztxV?utm_source=pull-request&utm_medium=comment)

Sent with 💌 from NxCloud.

pkg-pr-new[bot] commented 1 week ago

Open in Stackblitz

@ngxs/devtools-plugin

``` yarn add https://pkg.pr.new/@ngxs/devtools-plugin@2256.tgz ```

@ngxs/form-plugin

``` yarn add https://pkg.pr.new/@ngxs/form-plugin@2256.tgz ```

@ngxs/hmr-plugin

``` yarn add https://pkg.pr.new/@ngxs/hmr-plugin@2256.tgz ```

@ngxs/router-plugin

``` yarn add https://pkg.pr.new/@ngxs/router-plugin@2256.tgz ```

@ngxs/storage-plugin

``` yarn add https://pkg.pr.new/@ngxs/storage-plugin@2256.tgz ```

@ngxs/store

``` yarn add https://pkg.pr.new/@ngxs/store@2256.tgz ```

@ngxs/websocket-plugin

``` yarn add https://pkg.pr.new/@ngxs/websocket-plugin@2256.tgz ```

commit: 4c36c5c

bundlemon[bot] commented 1 week ago

BundleMon

Files updated (1) Status | Path | Size | Limits :------------: | ------------ | :------------: | :------------: :white_check_mark: | fesm2022/ngxs-store.mjs
| 100.84KB (+126B +0.12%) | 103KB / +0.5%
Unchanged files (5) Status | Path | Size | Limits :------------: | ------------ | :------------: | :------------: :white_check_mark: | fesm2022/ngxs-store-internals.mjs
| 11.33KB | 13KB / +0.5% :white_check_mark: | fesm2022/ngxs-store-internals-testing.mjs
| 6.83KB | 7KB / +0.5% :white_check_mark: | fesm2022/ngxs-store-operators.mjs
| 6.22KB | 7KB / +0.5% :white_check_mark: | fesm2022/ngxs-store-plugins.mjs
| 2.04KB | 3KB / +0.5% :white_check_mark: | fesm2022/ngxs-store-experimental.mjs
| 1.4KB | 2KB / +0.5%

Total files change +126B +0.1%

Groups updated (2) Status | Path | Size | Limits :------------: | ------------ | :------------: | :------------: :white_check_mark: | @ngxs/store(fesm2022)[gzip]
./fesm2022/*.mjs
| 30.88KB (+39B +0.12%) | +1% :white_check_mark: | @ngxs/store(esm2022)[gzip]
./esm2022/**/*.mjs
| 224.06KB (-385B -0.17%) | +1%

Final result: :white_check_mark:

View report in BundleMon website ➡️


Current branch size history | Target branch size history

bundlemon[bot] commented 1 week ago

BundleMon (NGXS Plugins)

Unchanged files (9) Status | Path | Size | Limits :------------: | ------------ | :------------: | :------------: :white_check_mark: | Plugins(fesm2022)[gzip]
storage-plugin/fesm2022/ngxs-storage-plugin.m
js
| 4.09KB | +0.5% :white_check_mark: | Plugins(fesm2022)[gzip]
router-plugin/fesm2022/ngxs-router-plugin.mjs
| 3.01KB | +0.5% :white_check_mark: | Plugins(fesm2022)[gzip]
hmr-plugin/fesm2022/ngxs-hmr-plugin.mjs
| 2.61KB | +0.5% :white_check_mark: | Plugins(fesm2022)[gzip]
websocket-plugin/fesm2022/ngxs-websocket-plug
in.mjs
| 2.58KB | +0.5% :white_check_mark: | Plugins(fesm2022)[gzip]
form-plugin/fesm2022/ngxs-form-plugin.mjs
| 2.52KB | +0.5% :white_check_mark: | Plugins(fesm2022)[gzip]
devtools-plugin/fesm2022/ngxs-devtools-plugin
.mjs
| 2.17KB | +0.5% :white_check_mark: | Plugins(fesm2022)[gzip]
logger-plugin/fesm2022/ngxs-logger-plugin.mjs
| 2.03KB | +0.5% :white_check_mark: | Plugins(fesm2022)[gzip]
storage-plugin/fesm2022/ngxs-storage-plugin-i
nternals.mjs
| 875B | +0.5% :white_check_mark: | Plugins(fesm2022)[gzip]
router-plugin/fesm2022/ngxs-router-plugin-int
ernals.mjs
| 411B | +0.5%

No change in files bundle size

Unchanged groups (1) Status | Path | Size | Limits :------------: | ------------ | :------------: | :------------: :white_check_mark: | All Plugins(fesm2022)[gzip]
./*-plugin/fesm2022/*.mjs
| 20.28KB | +0.5%

Final result: :white_check_mark:

View report in BundleMon website ➡️


Current branch size history | Target branch size history

bundlemon[bot] commented 1 week ago

BundleMon (Integration Projects)

Files updated (2) Status | Path | Size | Limits :------------: | ------------ | :------------: | :------------: :white_check_mark: | Main bundles(Gzip)
hello-world-ng18/dist-integration/browser/mai
n-(hash).js
| 71.51KB (+21B +0.03%) | +1% :white_check_mark: | Main bundles(Gzip)
hello-world-ng16/dist-integration/main.(hash)
.js
| 67.41KB (-35B -0.05%) | +1%
Unchanged files (1) Status | Path | Size | Limits :------------: | ------------ | :------------: | :------------: :white_check_mark: | Main bundles(Gzip)
hello-world-ng17/dist-integration/main.(hash)
.js
| 68.37KB | +1%

Total files change -17B -0.01%

Final result: :white_check_mark:

View report in BundleMon website ➡️


Current branch size history | Target branch size history

codeclimate[bot] commented 1 week ago

Code Climate has analyzed commit 4c36c5c5 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.0% change).

View more on Code Climate.