Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function bindMethods (object, methodsToBind) {
for (let method of methodsToBind) {
object[method] = object[method].bind(object)
}
}
function getScopedModelName (key) {
return `$${key}`
}
// ----------------------------------------------
// Monkey patches of ShareDB and Racer
// ----------------------------------------------
// Patch applying sharedb operations to prevent extra rerender from triggering
const oldHandleOp = SharedbDoc.prototype._handleOp
SharedbDoc.prototype._handleOp = function () {
let value
batching.batch(() => {
value = oldHandleOp.apply(this, arguments)
})
return value
}
const BATCH_SETTERS = ['_mutate', '_setEach', '_setDiff', '_setDiffDeep']
for (let methodName of BATCH_SETTERS) {
const oldMethod = racer.Model.prototype[methodName]
racer.Model.prototype[methodName] = function () {
let value
batching.batch(() => {
value = oldMethod.apply(this, arguments)
for (let method of methodsToBind) {
object[method] = object[method].bind(object)
}
}
function getScopedModelName (key) {
return `$${key}`
}
// ----------------------------------------------
// Monkey patches of ShareDB and Racer
// ----------------------------------------------
// Patch applying sharedb operations to prevent extra rerender from triggering
const oldHandleOp = SharedbDoc.prototype._handleOp
SharedbDoc.prototype._handleOp = function () {
let value
batching.batch(() => {
value = oldHandleOp.apply(this, arguments)
})
return value
}
const BATCH_SETTERS = ['_mutate', '_setEach', '_setDiff', '_setDiffDeep']
for (let methodName of BATCH_SETTERS) {
const oldMethod = racer.Model.prototype[methodName]
racer.Model.prototype[methodName] = function () {
let value
batching.batch(() => {
value = oldMethod.apply(this, arguments)
})