Replies: 3 comments 1 reply
-
Hey,
Huge. Those promises will have to bubble up all the way to the top level,
so the whole code path from that function call to the `evaluateXPath`
function needs to handle async code. We used to have something for this
(it's still remnant in the `evaluatexpathtoasynciterator` code (
https://github.com/FontoXML/fontoxpath/blob/master/src/evaluateXPathToAsyncIterator.ts),
but we ended up not using it. So that whole path was (from Fonto) only used
in unit tests. Don't forget, all the places where that async
`evaluateXPathToAsyncIterator` is used also needs to be asynchronous.
Something about releasing Zalgo.
So, instead, we went for this: a promise is nothing more than a function
that returns a 'loading' placeholder at first, and a 'resolved value'
later. Now you only need a signal that the load is completed and your
function is invalidated. In Fonto we have a stable dependency tracking /
indexing framework we can utilise for that.
But you don't have a dependency framework in place, and Fonto's is not open
sourced. You will have to do something else.
I'd approach it like this:
1. A single event source / pub-sub / notifier / however you want to call
it that can be called to signal that your XPath changed.
2. In a custom function, see if there is an earlier promise already
resolved. If so, just return the resolved value, if not, start a request
and return a 'loading' placeholder. We used a pattern like `map{"status":
"resolved" | "in-flight", "value": "the resolved thing"}`
3. After the request is done, notify that to your pub/sub whatever you
made in step #1
4. Repeat until there are no more requests in flight (or in the case of
an application, forever: stuff can change, other things can invalidate your
event source, etcetera)
Are you building an application that updates itself every so often or
something that just runs once?
Kindest regards,
Martin
…On Thu, 17 Oct 2024 at 12:05, Mark Hebden ***@***.***> wrote:
Hi,
I assume this will be non trivial. But we are looking at adding digest
support via a custom function using the Web Crypto API
https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
However the methods are all promise based, which currently doesn't work
with the custom function register callback.
So I was wondering what sort of effort would be involved to support this?
Thanks.
—
Reply to this email directly, view it on GitHub
<#657>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABGKEJHIMX4PD3YBUU25473Z36DXLAVCNFSM6AAAAABQDL2FNGVHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZXGMZTCMBVGY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks for the prompt and detailed response. I had assumed as much :) Its essentially an XForms based application so potentially plenty of updates. I will look into your suggestion further. |
Beta Was this translation helpful? Give feedback.
0 replies
-
XForms, cool! Check Fore (https://github.com/jinntec/Fore). It's a project
I am also working with. We did not go into promises yet, but it's always
fun to look at other solutions that take roughly the same path.
…On Thu, 17 Oct 2024 at 15:15, Mark Hebden ***@***.***> wrote:
Thanks for the prompt and detailed response. I had assumed as much :)
Its essentially an XForms based application so potentially plenty of
updates. I will look into your suggestion further.
Thanks again.
—
Reply to this email directly, view it on GitHub
<#657 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABGKEJDZBVDYKT2HJ3YRTKLZ36Z6LAVCNFSM6AAAAABQDL2FNGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTAOJXGE3DEOA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I assume this will be non trivial. But we are looking at adding digest support via a custom function using the Web Crypto API https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
However the methods are all promise based, which currently doesn't work with the custom function register callback.
So I was wondering what sort of effort would be involved to support this?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions