fastn loading state #1513
Closed
harshdoesdev
started this conversation in
Ideas & RFCs
Replies: 2 comments 3 replies
-
Since this is pure JavaScript need let's not create mutable fastn variable and instead aadd an on load method to the fastn JS library so people can pass their onload callbacks and they will be call at the right time. Does this work? |
Beta Was this translation helpful? Give feedback.
3 replies
-
This is implemented. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There should be a way to check if
fastn-js
has loaded and completely initialized. This will allow users to properly handle the loading state and ensure that all fastn dependencies have been loaded and hydration is complete. Currently, users don't have a built-in and stable method of handling this, leading to unexpected behaviors if the user is using custom JavaScript. Even in native fastn, there should be a way of handling it, similar toftd.dark-mode
.My proposal is that there should be a global variable, like
ftd.dark-mode
, specifically for handling the loading state. We can call itftd.loaded-state
or something similar. It should be mutable, with its initial value set toloading
. After everything has loaded, in the post-init callback, we can update it toloaded
. Users can subscribe to this mutable and write their code accordingly to handle the loaded state, such as displaying/hiding a loading screen, etc.For advanced users, we can also emit a CustomEvent like
fastn-loaded-state-changed
, and the users can subscribe to this event and call some function to do post-init stuff.cc: @Arpita-Jaiswal @amitu
Beta Was this translation helpful? Give feedback.
All reactions