Composing Handlers?
See original GitHub issueHello, Is Is possible to using multiple levels of handler? for exmpale:
bot.onEvent(mainHandler)
const mainHandler = new LineHandler()
.onFollow(async context => {
return true
}, followHandler)
.onUnfollow(async context => {
return true
}, unfollowHandler)
.onEvent(middleware([
termAndServiceAgreement,
isLoggedIn,
eventHandlers
]))
.onError(async (context, err) => {
await context.sendText(err)
})
.onUnhandled(doNothing)
const eventHandlers = new LineHandler()
.onEvent(async context => {
const answer = 'somthing';
switch (answer) {
case case1:
context([]);
break;
case case2:
const anotherHandler = handler1.build()
anotherHandler(context)
break;
default:
// code
doNothing()
}
})
const handler1 = new LineHandler()
.onEvent(async context => {
// do something
})
I see there bottender-compose, but it seems i can’t do something in the second parameter, only send actions.
bot.onEvent(
condition([
[context => false, sendText('a')],
[context => false, sendText('b')],
[context => true, sendText('c')],
])
);
what if i i wanna check something in context.state and call 3r party services or pass to another event handler??
Thanks~~~
Issue Analytics
- State:
- Created 5 years ago
- Comments:9
Top Results From Across the Web
Side-effects in Compose - Android Developers
A side-effect is a change to the state of the app that happens outside the scope of a composable function. Due to composables'...
Read more >Full Guide to Jetpack Compose Effect Handlers - YouTube
The new effect handlers in Jetpack Compose can be quite a pain to deal with if you don't fully understand their purpose.
Read more >Rust's Iron Framework: Composing Handlers | by Eric Opines
I'm learning Iron and its ecosystem as I work through this application. It could be there are better ways of doing things using...
Read more >Jetpack Compose Effect Handlers - by Jorge Castillo
Used for notifying state updates to objects not managed by Compose. For effects that do not require dispose. Runs after every successful ...
Read more >Jetpack Compose Effect Handlers - Jorge Castillo
Jetpack Compose Effect Handlers. Learn how to run your side effects bound to the @Composable lifecycle. This post has been moved to the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @yusef-ho ,
You can try use
DEBUG
environment varaible to check incoming events, then you may find out what events are triggering what actions.https://bottender.js.org/docs/Guides-Troubleshooting#i-want-to-know-if-therere-incoming-requests-to-my-bot
I’m going to close this issue.