enigmatic 0.21.2 → 0.21.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/enigmatic.js +10 -2
- package/package.json +1 -1
- package/tests/test-state.html +2 -0
package/enigmatic.js
CHANGED
|
@@ -101,7 +101,8 @@ if (window.components) {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
w.state = new Proxy({}, {
|
|
104
|
-
set: (obj, prop, value) => {
|
|
104
|
+
set: async (obj, prop, value) => {
|
|
105
|
+
await w.ready()
|
|
105
106
|
console.log('state change:', prop, value)
|
|
106
107
|
if (this[prop] === value) {
|
|
107
108
|
return true
|
|
@@ -121,7 +122,14 @@ w.state = new Proxy({}, {
|
|
|
121
122
|
|
|
122
123
|
w.get = async (url, options = {}, transform, key) => {
|
|
123
124
|
console.log(`fetching ${url}`)
|
|
124
|
-
let data
|
|
125
|
+
let data
|
|
126
|
+
if (url.startsWith('{') || url.startsWith('[')) {
|
|
127
|
+
data = JSON.parse(url)
|
|
128
|
+
} else {
|
|
129
|
+
let f = await fetch(url, options)
|
|
130
|
+
if (!f.ok) throw Error(`Could not fetch ${url}`)
|
|
131
|
+
data = await f.json()
|
|
132
|
+
}
|
|
125
133
|
if (transform) {
|
|
126
134
|
console.log('transforming ' + data)
|
|
127
135
|
data = transform(data)
|
package/package.json
CHANGED