GP
eachFrame :: C.Context2D -> C.CanvasImageSource -> Effect Unit
eachFrame ctx img = E.subscribe event draw *> pure unit
where
event = EA.animationFrame *> updateScene
draw d = drawCharacter ctx img d
withImage :: String -> (C.CanvasImageSource -> Effect Unit) -> Effect Unit
withImage path f = C.tryLoadImage path $ \mimg -> case mimg of
Just img -> f img
Nothing -> throwException $ error ("Could not load image from path: " <> path)
initWithCanvas :: C.CanvasElement -> Effect Unit
initWithCanvas c = do
ctx <- C.getContext2D c
withImage character (eachFrame ctx)
pure unit
Почему E.subscribe event draw *> pure unit вот так я попадаю в draw
а join $ E.subscribe event draw вот так не попадаю
