Async compiler functions?

29 views
Skip to first unread message

Gage Peterson

unread,
Apr 16, 2021, 5:34:31 PM4/16/21
to unpoly

I tried to look around the code to see how things are done but sadly I'm not super familiar with CoffeeScript. Is there a way to make a function that will compile a piece of HTML before it's rendered? More or less pause the page transition till some async thing happens?

I know that's a weird thing to do but I'm trying to implement end-to-end encryption but I hate constantly seeing the decrypting state every time you visit a page. I was thinking I could use transitions to pause the page rendering till after the HTML has been replaced with the decrypted state, but I'm not sure that'll work.

Tell me if this is crazy 😆

Henning Koch

unread,
Apr 17, 2021, 5:15:06 AM4/17/21
to unp...@googlegroups.com
Hi Gage,

there is no way for a compiler function to delay the fragment insertion
into the DOM. You can do async things in a compiler, but the element
will be rendered in the current execution task.

Maybe your compiler could hide the element (or show some "decrypting..."
indicator) and show it when done?

Clever idea with using a custom transition function to delay the page
rendering. At the point the transition function starts both the old and
new fragment are already in the DOM (moved into the same position to
shared elements overlay each other exactly). Your function could check
if the new fragment contains encrypted elements. If yes it would hide
the new fragment and delay the transition until your decrypting compiler
emits an decryption:done event or similar.

Best regards
Henning

Am 16.04.2021 um 23:34 schrieb Gage Peterson:
>
> I tried to look around the code to see how things are done but sadly I'm
> not super familiar with CoffeeScript. Is there a way to make a function
> that will compile a piece of HTML /before/ it's rendered? More or less
> pause the page transition till some async thing happens?
>
> I know that's a weird thing to do but I'm trying to implement end-to-end
> encryption but I hate constantly seeing the decrypting state every time
> you visit a page. I was thinking I could use transitions to pause the
> page rendering till after the HTML has been replaced with the decrypted
> state, but I'm not sure that'll work.
>
> Tell me if this is crazy 😆
>
> --
> You received this message because you are subscribed to the Google
> Groups "unpoly" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to unpoly+un...@googlegroups.com
> <mailto:unpoly+un...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/unpoly/313e2449-93e0-4a9f-a4d0-c98e5427421bn%40googlegroups.com
> <https://groups.google.com/d/msgid/unpoly/313e2449-93e0-4a9f-a4d0-c98e5427421bn%40googlegroups.com?utm_medium=email&utm_source=footer>.

Gage Peterson

unread,
Apr 19, 2021, 6:39:39 PM4/19/21
to unpoly
I currently just change the text to "Decrypting" till it's done, which works, but often the decrypting is done super fast so it leads to a weird flickery experience, same for when I want a React component to render (for complex stuff like a date picker, tag picker, or rich text editor).

I haven't had a chance to try out the transition idea, might dive into that more soon.

Thanks for your reply!
Reply all
Reply to author
Forward
0 new messages