@live-change/vue3-ssr 0.1.6 → 0.1.7

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.
Files changed (3) hide show
  1. package/clientApi.js +1 -1
  2. package/index.js +38 -3
  3. package/package.json +1 -1
package/clientApi.js CHANGED
@@ -2,7 +2,7 @@ import { createReactiveObject } from '@live-change/vue3-components'
2
2
  import * as lcapi from '@live-change/vue-api'
3
3
  import * as lcdao from '@live-change/dao'
4
4
  import { reactiveMixin, reactivePrefetchMixin, ReactiveObservableList } from '@live-change/dao-vue3'
5
- import { SockJsConnection } from '@live-change/dao-sockjs'
5
+ import SockJsConnection from '@live-change/dao-sockjs'
6
6
 
7
7
  function clientApi(settings = {}) {
8
8
  const dao = new lcdao.Dao(window.__CREDENTIALS__, {
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { getCurrentInstance } from 'vue'
2
- import { live as d3live } from '@live-change/dao-vue3'
1
+ import { getCurrentInstance, onUnmounted } from 'vue'
2
+ import { live as d3live, RangeBuckets } from '@live-change/dao-vue3'
3
3
 
4
4
  function path(app) {
5
5
  app = app || getCurrentInstance()
@@ -27,6 +27,41 @@ function live(path) {
27
27
  return d3live(api, path)
28
28
  }
29
29
 
30
+ async function rangeBuckets(pathFunction, options, app) {
31
+ app = app || getCurrentInstance()
32
+ const api = app.appContext.config.globalProperties.$lc
33
+ const extendedPathFunction = (range) => pathFunction(range, api.fetch)
34
+ const buckets = new RangeBuckets(api, extendedPathFunction, options)
35
+ if(app) {
36
+ onUnmounted(() => {
37
+ buckets.dispose()
38
+ })
39
+ } else {
40
+ console.error("live fetch outside component instance - possible memory leak")
41
+ }
42
+ await buckets.wait()
43
+ return {
44
+ buckets: buckets.buckets,
45
+ loadTop: () => buckets.loadTop(),
46
+ loadBottom: () => buckets.loadBottom(),
47
+ dropTop: () => buckets.dropTop(),
48
+ dropBottom: () => buckets.dropBottom(),
49
+ canLoadTop: () => buckets.isTopLoadPossible(),
50
+ canLoadBottom: () => buckets.isBottomLoadPossible(),
51
+ }
52
+ }
53
+
54
+ function reverseRange(range) {
55
+ return {
56
+ gt: range.lt,
57
+ gte: range.lte,
58
+ lt: range.gt == '' ? '\xFF\xFF\xFF\xFF' : range.gt,
59
+ lte: range.gte,
60
+ limit: range.limit,
61
+ reverse: !range.reverse
62
+ }
63
+ }
64
+
30
65
  function client(app) {
31
66
  app = app || getCurrentInstance()
32
67
  return app.appContext.config.globalProperties.$lc.client
@@ -37,4 +72,4 @@ function uid(app) {
37
72
  return app.appContext.config.globalProperties.$lc.uid
38
73
  }
39
74
 
40
- export { path, api, view, actions, live, client, uid }
75
+ export { path, api, view, actions, live, client, uid, rangeBuckets, reverseRange }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/vue3-ssr",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Live Change Framework - vue components",
5
5
  "main": "index.js",
6
6
  "scripts": {