Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@live-change/framework

Package Overview
Dependencies
Maintainers
1
Versions
316
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@live-change/framework - npm Package Compare versions

Comparing version 0.3.17 to 0.3.18

73

lib/runtime/ReaderModel.js

@@ -25,3 +25,3 @@ const ReactiveDao = require("@live-change/dao")

indexRangePath(index, range = {}) {
indexRangePath(index, range = {}, options = {}) {
if(typeof range != 'object' || Array.isArray(range)) {

@@ -33,10 +33,42 @@ const values = Array.isArray(range) ? range : [range]

return ['database', 'query', this.service.databaseName, `(${
/// TODO: observe objects
async (input, output, { tableName, indexName, range }) => {
async (input, output, { tableName, indexName, range, options }) => {
if(range.reverse) output.setReverse(true)
let objectObservers = new Map()
let objectMapper = obj => obj
if(options.idFromIndex) objectMapper = (obj, ind) => obj && ({ ...obj, id: ind.id, to: ind.to })
const objectChangeCallback = (id, ind) => {
let object
return async (objp) => {
const obj = objectMapper(objp, ind)
output.change(obj, object)
object = obj
}
}
const mapper = async (res) => input.table(tableName).object(res.to).get()
await (await input.index(indexName)).range(range).onChange(async (obj, oldObj) => {
output.change(obj && await mapper(obj), oldObj && await mapper(oldObj))
let cb
if(obj && obj.to) {
cb = objectChangeCallback(obj.to, obj)
const currentObserver = objectObservers.get(obj.to)
if(currentObserver) {
currentObserver.reader.unobserve(currentObserver.observer)
}
const reader = input.table(tableName).object(obj.to)
const observer = await reader.onChange(obj => cb(obj))
objectObservers.set(obj.to, { reader, observer })
} else if(oldObj && oldObj.to) {
const currentObserver = objectObservers.get(oldObj.to)
if(currentObserver) {
currentObserver.reader.unobserve(currentObserver.observer)
objectObservers.delete(oldObj.to)
}
cb(null)
}
output.change(
obj && objectMapper(await mapper(obj), obj),
objectMapper(oldObj && await mapper(oldObj), oldObj)
)
})
}
})`, { indexName: this.tableName+'_'+index, tableName: this.tableName, range }]
})`, { indexName: this.tableName+'_'+index, tableName: this.tableName, range, options }]
}

@@ -51,7 +83,20 @@

return ['database', 'queryObject', this.service.databaseName, `(${
/// TODO: observe object
async (input, output, { tableName, indexName, range }) => {
const mapper = async (res) => input.table(tableName).object(res.to).get()
let objectReader = null
let objectObserver = null
let object = null
const objectChangeCallback = async (obj, oldObj) => {
output.change(obj, object)
object = obj
}
await (await input.index(indexName)).range(range).onChange(async (obj, oldObj) => {
output.change(obj && await mapper(obj), oldObj && await mapper(oldObj))
if(objectObserver) await objectReader.unobserve(objectObserver)
if(obj.to) {
objectReader = input.table(tableName).object(obj.to)
objectObserver = await objectReader.onChange(objectChangeCallback)
} else {
objectObserver = null
objectReader = null
output.change(null, object)
}
})

@@ -109,12 +154,12 @@ }

indexRangeObservable(index, range) {
return this.service.dao.observable(this.indexRangePath(index, range), ReactiveDao.ObservableList)
indexRangeObservable(index, range, options = {}) {
return this.service.dao.observable(this.indexRangePath(index, range, options), ReactiveDao.ObservableList)
}
async indexRangeGet(index, range) {
return this.service.dao.get(this.indexRangePath(index, range), ReactiveDao.ObservableList)
async indexRangeGet(index, range, options = {}) {
return this.service.dao.get(this.indexRangePath(index, range, options), ReactiveDao.ObservableList)
}
indexObjectObservable(index, range) {
return this.service.dao.observable(this.indexObjectPath(index, range))
indexObjectObservable(index, range, options = {}) {
return this.service.dao.observable(this.indexObjectPath(index, range, options))
}

@@ -121,0 +166,0 @@

10

lib/runtime/View.js

@@ -12,12 +12,2 @@ const ReactiveDao = require('@live-change/dao')

async prepareRequest(parameters, clientData, queryType) {
const context = {
service: this.service, client: clientData
}
//console.log("PARAMETERS", JSON.stringify(parameters), "DEFN", this.definition.properties)
parameters = await prepareParameters(parameters, this.definition.properties, this.service)
//console.log("PREPARED PARAMETERS", parameters)
return await this.definition.read(parameters, context, queryType, this.service)
}
async observable(parameters, clientData) {

@@ -24,0 +14,0 @@ const context = {

{
"name": "@live-change/framework",
"version": "0.3.17",
"version": "0.3.18",
"description": "Live Change Framework - ultimate solution for real time mobile/web apps",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc