packages feed

ghcjs-dom-javascript-0.10.0.0: src/GHCJS/DOM/JSFFI/Generated/VideoFrameOutputCallback.hs

{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from webcodecs (webref). Do not edit.
module GHCJS.DOM.JSFFI.Generated.VideoFrameOutputCallback
       (newVideoFrameOutputCallback, newVideoFrameOutputCallbackSync, newVideoFrameOutputCallbackAsync, VideoFrameOutputCallback)
       where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import GHCJS.Types (JSVal, JSString)
import GHCJS.Foreign (jsUndefined, jsNull)
import Data.Coerce (coerce)
import GHC.JS.Foreign.Callback (OnBlocked(..), syncCallback1, asyncCallback1)
import GHCJS.DOM.Types
import GHCJS.DOM.JSFFI.Generated.Enums

newVideoFrameOutputCallback :: (MonadDOM m) => (VideoFrame -> IO ()) -> m VideoFrameOutputCallback
newVideoFrameOutputCallback callback = liftDOM ((VideoFrameOutputCallback . coerce) <$> syncCallback1 ContinueAsync (\ output -> do
          output' <- fromJSValUnchecked output
          callback output'))

newVideoFrameOutputCallbackSync :: (MonadDOM m) => (VideoFrame -> IO ()) -> m VideoFrameOutputCallback
newVideoFrameOutputCallbackSync callback = liftDOM ((VideoFrameOutputCallback . coerce) <$> syncCallback1 ThrowWouldBlock (\ output -> do
          output' <- fromJSValUnchecked output
          callback output'))

newVideoFrameOutputCallbackAsync :: (MonadDOM m) => (VideoFrame -> IO ()) -> m VideoFrameOutputCallback
newVideoFrameOutputCallbackAsync callback = liftDOM ((VideoFrameOutputCallback . coerce) <$> asyncCallback1 (\ output -> do
          output' <- fromJSValUnchecked output
          callback output'))