Open yueyinqiu opened 1 year ago
@yueyinqiu This is totally fine! Let me try to implement something like this actually. I've been away from the project for a bit. Aka, sorry for the late response. But last time I was working on the code, I was doing something very similar. I was reworking the callback completely as well. So, we both were funnily on the same page! The current version of the callback was implemented by the project I branched from. There's reasons to have it the way he coded it. But since we're both on the same page, it means we both understand the inherit disadvantages of the current callback system.
As far as I know, the version the old code used with callback is good for extreme high flow scenarios. At least, that's what Chat GPT said haha. Because I still struggle to grasp the concept of the real advantages of why it was coded that way. But yes, I 100% agree.
My company finished a huge portion of the project recently which puts me on the path towards actually implementing the code I published here. But now that my daily life will be implementing this code, I'll be back full force to focus on it and updates like this will be definitely implemented :)
I'm going to leave this comment thread open as I work on this.
Hello, I'm here again.
Actually I was trying to find out 'what will happen when the primary key get duplicate' but haven't caught any exceptions. So I dived into your code and fount that all the
JSException
s are caught there and theActionCompleted
event was raised. This confused me a lot since there seems to be no reason to do that, and both you and the users will find it inconvenient to deal with the event and the transactions.Well, later when I found that all the js functions are returning nothing in direct but just using
.then
and.catch
, I think I understand all of that. However, Blazor JavaScript interop could directly deal with promises:Meanwhile, an async js method might be a better choice:
And
CancellationTokenSource
s are even able to be used to cancel the promises: Abort a long-running JavaScript functionSo my suggestion is to avoid using callbacks but to use the above measures instead. Hope you won't hate me this time, since it will be a really great change to the whole project. Of course, it's just a suggestion and the choice is yours.