Skip to content

Commit

Permalink
perf(getter): set only true type value returns
Browse files Browse the repository at this point in the history
otherwise, use stork.set() manually
  • Loading branch information
K-NRS committed Mar 6, 2021
1 parent 31ec276 commit 5a4ddfb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type": "git"
},
"name": "storken",
"version": "2.0.2",
"version": "2.0.3",
"description": "Storken is a hook-based fully extendable and minimal state manager for React.",
"author": "Kerem Noras <[email protected]>",
"main": "dist/storken.js",
Expand Down
8 changes: 5 additions & 3 deletions src/storken.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ export class Storken {
)
.then(getterValue => {
this.dispatchEvent('getted', getterValue, ...args)
this.set(getterValue, { force: true, disableSetter: this.opts?.disableSetterOnGetter || true })
if (getterValue) {
this.set(getterValue, { force: true, disableSetter: this.opts?.disableSetterOnGetter || true })
}
this.load(false)
return getterValue
})
Expand Down Expand Up @@ -139,8 +141,8 @@ export class Storken {
Promise.resolve(
typeof this.opts.setter === 'function'
? typeof this.opts.setter?.then === 'function'
? await this.opts.setter(this, ...this?.args)
: this.opts.setter(this, ...this?.args)
? await this.opts.setter(this, ...this?.args)
: this.opts.setter(this, ...this?.args)
: this.opts.setter
)
.then(() => { this.load(false) })
Expand Down

0 comments on commit 5a4ddfb

Please sign in to comment.