Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
t('useGlobalCache: must be writable', async t => {
globalCache.set('x', 1)
let log = []
enhook(() => {
let [x, setX] = useGlobalCache('x')
log.push(x)
setX(2)
})()
t.deepEqual(log, [1])
await tick(3)
t.deepEqual(log, [1, 2])
globalCache.delete('x')
t.end()
})
t('useGlobalCache: basic', async t => {
globalCache.set('count', 0)
let log = []
let f = enhook(() => {
let [count, setCount] = useGlobalCache('count')
log.push(count)
useEffect(() => {
setCount(1)
}, [])
})
f()
t.deepEqual(log, [0])
await frame(4)
t.deepEqual(log, [0, 1])
globalCache.delete('count')
t.end()
})
function set(key, value) {
return cache.set(key, value);
}
return DialogSchema.find().then(model => {
debug('Email Talk');
const data = { emails: {}, flow: Convert.convert(model), map: model };
cache.set('dialogCache', {
data,
time: moment.now(),
});
return resolve(
`Updated: ${stAmount} - Dialog Amount: ${
Object.keys(data.flow).length
}`,
);
});
}