@knowlearning/agents 0.9.28 → 0.9.29

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.
@@ -97,8 +97,17 @@ export default function EmbeddedAgent() {
97
97
  }
98
98
 
99
99
  function watch(scope, fn, user, domain) {
100
+ let watchingPath = false
101
+ if (scope && scope.length === 1) {
102
+ watchingPath = true
103
+ scope = scope[0]
104
+ }
105
+ // TODO: actually allow watching at paths in embedded
106
+
100
107
  tagIfNotYetTaggedInSession('subscribed', scope)
101
108
 
109
+ const wrappedFn = update => fn(watchingPath ? update.state : update)
110
+
102
111
  const key = (
103
112
  environment()
104
113
  .then(async ({ auth, domain:rootDomain }) => {
@@ -108,14 +117,14 @@ export default function EmbeddedAgent() {
108
117
 
109
118
  const state = await send({ type: 'state', scope, user, domain })
110
119
  const metadata = await send({ type: 'metadata', scope, user, domain })
111
- fn({ state, patch: null, ii: metadata.ii })
120
+ wrappedFn({ state, patch: null, ii: metadata.ii })
112
121
  sentUpdates[key] = metadata.ii
113
122
  if (!watchers[key]) watchers[key] = []
114
- watchers[key].push(fn)
123
+ watchers[key].push(wrappedFn)
115
124
  return key
116
125
  })
117
126
  )
118
- return async () => removeWatcher(await key, fn)
127
+ return async () => removeWatcher(await key, wrappedFn)
119
128
  }
120
129
 
121
130
  async function patch(root, scopes) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowlearning/agents",
3
- "version": "0.9.28",
3
+ "version": "0.9.29",
4
4
  "description": "API for embedding applications in KnowLearning systems.",
5
5
  "main": "node.js",
6
6
  "browser": "browser.js",