Skip to content

Instantly share code, notes, and snippets.

@Kelin2025
Last active May 8, 2022 04:11
Show Gist options
  • Save Kelin2025/9384f65f3c6d32e842f02d37a241b2aa to your computer and use it in GitHub Desktop.
Save Kelin2025/9384f65f3c6d32e842f02d37a241b2aa to your computer and use it in GitHub Desktop.
Apicase watchers example
import { Container } from 'apicase'
export default new Container({
services: {
hello: {
url: '/hello',
watchers: [
(ctx, key, value) => {
switch (key) {
case 'calls':
console.log(`Service callled ${value} times`)
break
case 'result':
console.log('Look like result has changed', value)
break:
case 'pending':
console.log(value ? 'Call started' : 'Call finished')
break
default:
console.log('It just evolve', ctx)
}
}
]
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment