Last active
May 8, 2022 04:11
-
-
Save Kelin2025/9384f65f3c6d32e842f02d37a241b2aa to your computer and use it in GitHub Desktop.
Apicase watchers example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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