Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store to localstorage on visibilty change #14

Open
rubenmoor opened this issue Oct 23, 2021 · 0 comments
Open

store to localstorage on visibilty change #14

rubenmoor opened this issue Oct 23, 2021 · 0 comments

Comments

@rubenmoor
Copy link
Owner

rubenmoor commented Oct 23, 2021

https://stackoverflow.com/questions/67028712/how-to-get-a-reflex-event-that-fire-on-visibilitychange-of-document

maybe similar to this code:

eReqResult <- postRender $ do
    fileReader <- liftJSM newFileReader
    let encoding = Just ("utf8" :: String)
    performEvent_ $ eFile <&> \f -> readAsText fileReader (Just f) encoding
    eText <- fmap catMaybes $
      wrapDomEvent fileReader (`on` load) $
        liftJSM $ do
          v <- getResult fileReader
          (fromJSVal <=< toJSVal) v
    dynEitherText <- holdDyn (Left "no file") (Right . Text.unpack <$> eText)
    postConfigNew dynEitherText (void eText)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant