8000 Use Function instead of JSVal. by dmjio · Pull Request #951 · dmjio/miso · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Use Function instead of JSVal. #951

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

Merged
merged 1 commit into from
May 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/Miso/Canvas.hs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ import Control.Monad (void, liftM, ap, liftM2)
import Data.Kind (Type)
import Language.Javascript.JSaddle ( JSM, JSVal, (#), fromJSVal
, (<#), toJSVal, (!)
, liftJSM
, liftJSM, Function
, ToJSVal, MakeObject, (<##)
#ifndef GHCJS_BOTH
, MonadJSM(..)
Expand All @@ -172,13 +172,13 @@ import Miso.String (MisoString)
canvas
:: forall action
. [ Attribute action ]
-> JSM JSVal
-> JSM Function
-> View action
canvas attributes callback = node HTML "canvas" attrs []
where
attrs :: [ Attribute action ]
attrs = flip (:) attributes $ Event $ \_ obj _ _ ->
flip (FFI.set "draw") obj =<< callback
flip (FFI.set "draw") obj =<< toJSVal =<< callback
-----------------------------------------------------------------------------
-- | Element for drawing on a <canvas>, includes a @Canvas@ DSL.
-- Specialized to "2d" canvas.
Expand All @@ -188,10 +188,9 @@ canvas_
-> View action
canvas_ attributes canvas' =
canvas attributes $
toJSVal =<< do
FFI.syncCallback1 $ \domRef -> do
ctx <- domRef # ("getContext" :: MisoString) $ ["2d" :: MisoString]
void (interpret ctx canvas')
FFI.syncCallback1 $ \domRef -> do
ctx <- domRef # ("getContext" :: MisoString) $ ["2d" :: MisoString]
void (interpret ctx canvas')
-----------------------------------------------------------------------------
data PatternType = Repeat | RepeatX | RepeatY | NoRepeat
-----------------------------------------------------------------------------
Expand Down
0