Skip to content

Conversation

OnlyWick
Copy link
Contributor

The main purpose is to avoid the repeated storage of the same function.

const store = useCounterStore()
const test = () => {
  console.log("Hi, Wick");
}
store.$subscribe(test)  // subscriptions.length = 1
store.$subscribe(test)  // subscriptions.length = 2
store.$subscribe(test)  // subscriptions.length = 3

Using a Set can directly avoid this problem and reduce memory waste.

const store = useCounterStore()
const test = () => {
  console.log("Hi, Wick");
}
store.$subscribe(test)  // subscriptions.length = 1
store.$subscribe(test)  // subscriptions.length = 1
store.$subscribe(test)  // subscriptions.length = 1

Copy link

netlify bot commented Dec 20, 2024

Deploy Preview for pinia-playground ready!

Name Link
🔨 Latest commit 5cbd956
🔍 Latest deploy log https://app.netlify.com/sites/pinia-playground/deploys/67653024b72e070008ad1223
😎 Deploy Preview https://deploy-preview-2862--pinia-playground.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 20, 2024

Deploy Preview for pinia-official canceled.

Name Link
🔨 Latest commit 5cbd956
🔍 Latest deploy log https://app.netlify.com/sites/pinia-official/deploys/676530244b799100082d6469

Copy link

pkg-pr-new bot commented Dec 20, 2024

Open in Stackblitz

npm i https://pkg.pr.new/@pinia/nuxt@2862
npm i https://pkg.pr.new/pinia@2862
npm i https://pkg.pr.new/@pinia/testing@2862

commit: 5cbd956

Copy link

codecov bot commented Dec 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.72%. Comparing base (2071db2) to head (5cbd956).
Report is 8 commits behind head on v2.

Additional details and impacted files
@@            Coverage Diff             @@
##               v2    #2862      +/-   ##
==========================================
- Coverage   88.75%   88.72%   -0.03%     
==========================================
  Files          19       19              
  Lines        1449     1446       -3     
  Branches      226      226              
==========================================
- Hits         1286     1283       -3     
  Misses        162      162              
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@OnlyWick OnlyWick closed this by deleting the head repository Jan 14, 2025
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.

1 participant