Skip to content

Commit

Permalink
Merge pull request #18 from shoonia/rc-3
Browse files Browse the repository at this point in the history
rc.3
  • Loading branch information
shoonia authored Feb 20, 2024
2 parents b23f8e2 + d6458cf commit 37777ce
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 118 deletions.
4 changes: 2 additions & 2 deletions .size-limit.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
{
"path": "lib/index.cjs",
"import": "{ createStoreon }",
"limit": "604 B"
"limit": "597 B"
},
{
"path": "lib/index.js",
"import": "{ createStoreon }",
"limit": "333 B"
"limit": "328 B"
}
]
14 changes: 7 additions & 7 deletions lib/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ let createStoreon = (modules) => {
getState: get,
setState: set,

connect(...keys) {
let cb = keys.pop();
connect(...k) {
let c = k.pop();

subs.push({ keys, cb });
subs.push({ k, c });

return () => {
subs = subs.filter((i) => i.cb !== cb);
subs = subs.filter((i) => i.c !== c);
};
},

Expand All @@ -69,15 +69,15 @@ let createStoreon = (modules) => {

on('@changed', (_, changes) => {
subs.forEach((i) => {
let hasChanges = i.keys.some((key) => key in changes);
let hasChanges = i.k.some((key) => key in changes);

if (hasChanges) {
i.cb(state);
i.c(state);
}
});
});

return Promise.all(subs.map((i) => i.cb(state)));
return Promise.all(subs.map((i) => i.c(state)));
},
};
};
Expand Down
14 changes: 7 additions & 7 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ let createStoreon = (modules) => {
getState: get,
setState: set,

connect(...keys) {
let cb = keys.pop();
connect(...k) {
let c = k.pop();

subs.push({ keys, cb });
subs.push({ k, c });

return () => {
subs = subs.filter((i) => i.cb !== cb);
subs = subs.filter((i) => i.c !== c);
};
},

Expand All @@ -67,15 +67,15 @@ let createStoreon = (modules) => {

on('@changed', (_, changes) => {
subs.forEach((i) => {
let hasChanges = i.keys.some((key) => key in changes);
let hasChanges = i.k.some((key) => key in changes);

if (hasChanges) {
i.cb(state);
i.c(state);
}
});
});

return Promise.all(subs.map((i) => i.cb(state)));
return Promise.all(subs.map((i) => i.c(state)));
},
};
};
Expand Down
Loading

0 comments on commit 37777ce

Please sign in to comment.