@erickmerchant/framework
Advanced tools
Comparing version 40.3.0 to 41.0.0
58
main.js
@@ -661,32 +661,44 @@ const svgNamespace = 'http://www.w3.org/2000/svg' | ||
const app = { | ||
const callView = () => { | ||
viewCalled = false | ||
return Promise.resolve().then(() => { | ||
if (!viewCalled) { | ||
viewCalled = true | ||
view(state) | ||
} | ||
}) | ||
} | ||
const proxy = (state) => | ||
typeof state === 'object' | ||
? new Proxy(state, { | ||
set(state, key, val) { | ||
state[key] = val | ||
callView() | ||
return true | ||
} | ||
}) | ||
: state | ||
state = proxy(state) | ||
return { | ||
render(v) { | ||
view = v | ||
viewCalled = false | ||
callView() | ||
}, | ||
set state(val) { | ||
state = proxy(val) | ||
return Promise.resolve().then(() => { | ||
if (!viewCalled) { | ||
viewCalled = true | ||
view(state) | ||
} | ||
}) | ||
callView() | ||
}, | ||
commit(arg) { | ||
if (typeof arg === 'function') { | ||
state = arg(state) ?? state | ||
} else { | ||
state = arg | ||
} | ||
viewCalled = true | ||
if (view != null) { | ||
view(state) | ||
} | ||
get state() { | ||
return state | ||
} | ||
} | ||
return app | ||
} |
{ | ||
"name": "@erickmerchant/framework", | ||
"version": "40.3.0", | ||
"version": "41.0.0", | ||
"description": "A front-end framework.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/erickmerchant/framework#readme", |
@@ -11,7 +11,7 @@ # @erickmerchant/framework | ||
const decrement = () => { | ||
app.commit((current) => current - 1) | ||
app.state-- | ||
} | ||
const increment = () => { | ||
app.commit((current) => current + 1) | ||
app.state++ | ||
} | ||
@@ -18,0 +18,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19328
627