Skip to content

Commit

Permalink
file-reader example: Use new JS backend syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
sevanspowell committed May 3, 2024
1 parent 975d6ae commit e4b5016
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions examples/file-reader/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Miso.String
import Control.Concurrent.MVar

import GHCJS.Types
import GHCJS.Foreign.Callback
import GHC.JS.Foreign.Callback

-- | Model
data Model
Expand Down Expand Up @@ -71,17 +71,17 @@ viewModel Model {..} = view
, div_ [] [ text info ]
]

foreign import javascript unsafe "$r = new FileReader();"
foreign import javascript unsafe "(() => { return new FileReader(); })"
newReader :: IO JSVal

foreign import javascript unsafe "$r = $1.files[0];"
foreign import javascript unsafe "((x) => { return x.files[0]; })"
getFile :: JSVal -> IO JSVal

foreign import javascript unsafe "$1.onload = $2;"
foreign import javascript unsafe "((x, y) => { x.onload = y; })"
setOnLoad :: JSVal -> Callback (IO ()) -> IO ()

foreign import javascript unsafe "$r = $1.result;"
foreign import javascript unsafe "((x) => { return x.result; })"
getResult :: JSVal -> IO MisoString

foreign import javascript unsafe "$1.readAsText($2);"
foreign import javascript unsafe "((x, y) => { x.readAsText(y); })"
readText :: JSVal -> JSVal -> IO ()

0 comments on commit e4b5016

Please sign in to comment.