evt icon indicating copy to clipboard operation
evt copied to clipboard

Get return value from evt.post

Open iShawnWang opened this issue 3 years ago • 6 comments

Any idea about get return value or complete callback after evt.post

iShawnWang avatar Aug 09 '20 05:08 iShawnWang

Hi, As of now evt.post return post count... But I don't recall ever using the return value... I am open to breaking changes, could you describe your use case and maybe make a suggestion on how to change the API?

garronej avatar Aug 09 '20 09:08 garronej

@iShawnWang Would you please explain what you mean by "complete callback"?

garronej avatar Aug 10 '20 12:08 garronej

I am not sure if this meet the design principle of evt, maybe this meet my needs :

myEvt.post(params).then(returnValue => {
    // other logic
})

The postCount returnValue seems useless

Awesome library by the way ~

iShawnWang avatar Aug 16 '20 01:08 iShawnWang

I am not sure if this meet the design principle of evt, maybe this meet my needs :

myEvt.post(params).then(returnValue => {
    // other logic
})

I was thinking about something like that. When would you expect the then callback to be invoked? When all handlers have been called?
What would you want the retrunValue to be? The params ?

The postCount returnValue seems useless

Agreed

Awesome library by the way ~

🙏🙏

garronej avatar Aug 16 '20 11:08 garronej

When would you expect the then callback to be invoked? When all handlers have been called? What would you want the retrunValue to be? The params ?

Wow, things seems more complex than i think !, I didn't take multiple subscriber into account. In my opinion, the returnValue shuold be the value returned in the evt.attach. If there are multiple evt.attch for the same event, may be we can reference the design principle of webpack tappable

iShawnWang avatar Aug 18 '20 16:08 iShawnWang

Ok, this is food for thought, I will investigate. Thanks @iShawnWang

garronej avatar Aug 18 '20 16:08 garronej