{-# LANGUAGE PatternSynonyms #-}
-- For HasCallStack compatibility
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module JSDOM.Generated.NavigatorUserMediaErrorCallback
       (newNavigatorUserMediaErrorCallback,
        newNavigatorUserMediaErrorCallbackSync,
        newNavigatorUserMediaErrorCallbackAsync,
        NavigatorUserMediaErrorCallback)
       where
import Prelude ((.), (==), (>>=), return, IO, Int, Float, Double, Bool(..), Maybe, maybe, fromIntegral, round, realToFrac, fmap, Show, Read, Eq, Ord, Maybe(..))
import qualified Prelude (error)
import Data.Typeable (Typeable)
import Data.Traversable (mapM)
import Language.Javascript.JSaddle (JSM(..), JSVal(..), JSString, strictEqual, toJSVal, valToStr, valToNumber, valToBool, js, jss, jsf, jsg, function, asyncFunction, new, array, jsUndefined, (!), (!!))
import Data.Int (Int64)
import Data.Word (Word, Word64)
import JSDOM.Types
import Control.Applicative ((<$>))
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Enums

-- | <https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUserMediaErrorCallback Mozilla NavigatorUserMediaErrorCallback documentation> 
newNavigatorUserMediaErrorCallback ::
                                   (MonadDOM m) =>
                                     (NavigatorUserMediaError -> JSM ()) ->
                                       m NavigatorUserMediaErrorCallback
newNavigatorUserMediaErrorCallback :: forall (m :: * -> *).
MonadDOM m =>
(NavigatorUserMediaError -> JSM ())
-> m NavigatorUserMediaErrorCallback
newNavigatorUserMediaErrorCallback NavigatorUserMediaError -> JSM ()
callback
  = DOM NavigatorUserMediaErrorCallback
-> m NavigatorUserMediaErrorCallback
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
      (Callback (JSVal -> IO ()) -> NavigatorUserMediaErrorCallback
NavigatorUserMediaErrorCallback (Callback (JSVal -> IO ()) -> NavigatorUserMediaErrorCallback)
-> (Function -> Callback (JSVal -> IO ()))
-> Function
-> NavigatorUserMediaErrorCallback
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Function -> Callback (JSVal -> IO ())
forall a. Function -> Callback a
Callback (Function -> NavigatorUserMediaErrorCallback)
-> JSM Function -> DOM NavigatorUserMediaErrorCallback
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
         JSCallAsFunction -> JSM Function
function
           (\ JSVal
_ JSVal
_ [JSVal
error] ->
              JSVal -> JSM NavigatorUserMediaError
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked JSVal
error JSM NavigatorUserMediaError
-> (NavigatorUserMediaError -> JSM ()) -> JSM ()
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ NavigatorUserMediaError
error' -> NavigatorUserMediaError -> JSM ()
callback NavigatorUserMediaError
error'))

-- | <https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUserMediaErrorCallback Mozilla NavigatorUserMediaErrorCallback documentation> 
newNavigatorUserMediaErrorCallbackSync ::
                                       (MonadDOM m) =>
                                         (NavigatorUserMediaError -> JSM ()) ->
                                           m NavigatorUserMediaErrorCallback
newNavigatorUserMediaErrorCallbackSync :: forall (m :: * -> *).
MonadDOM m =>
(NavigatorUserMediaError -> JSM ())
-> m NavigatorUserMediaErrorCallback
newNavigatorUserMediaErrorCallbackSync NavigatorUserMediaError -> JSM ()
callback
  = DOM NavigatorUserMediaErrorCallback
-> m NavigatorUserMediaErrorCallback
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
      (Callback (JSVal -> IO ()) -> NavigatorUserMediaErrorCallback
NavigatorUserMediaErrorCallback (Callback (JSVal -> IO ()) -> NavigatorUserMediaErrorCallback)
-> (Function -> Callback (JSVal -> IO ()))
-> Function
-> NavigatorUserMediaErrorCallback
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Function -> Callback (JSVal -> IO ())
forall a. Function -> Callback a
Callback (Function -> NavigatorUserMediaErrorCallback)
-> JSM Function -> DOM NavigatorUserMediaErrorCallback
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
         JSCallAsFunction -> JSM Function
function
           (\ JSVal
_ JSVal
_ [JSVal
error] ->
              JSVal -> JSM NavigatorUserMediaError
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked JSVal
error JSM NavigatorUserMediaError
-> (NavigatorUserMediaError -> JSM ()) -> JSM ()
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ NavigatorUserMediaError
error' -> NavigatorUserMediaError -> JSM ()
callback NavigatorUserMediaError
error'))

-- | <https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUserMediaErrorCallback Mozilla NavigatorUserMediaErrorCallback documentation> 
newNavigatorUserMediaErrorCallbackAsync ::
                                        (MonadDOM m) =>
                                          (NavigatorUserMediaError -> JSM ()) ->
                                            m NavigatorUserMediaErrorCallback
newNavigatorUserMediaErrorCallbackAsync :: forall (m :: * -> *).
MonadDOM m =>
(NavigatorUserMediaError -> JSM ())
-> m NavigatorUserMediaErrorCallback
newNavigatorUserMediaErrorCallbackAsync NavigatorUserMediaError -> JSM ()
callback
  = DOM NavigatorUserMediaErrorCallback
-> m NavigatorUserMediaErrorCallback
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
      (Callback (JSVal -> IO ()) -> NavigatorUserMediaErrorCallback
NavigatorUserMediaErrorCallback (Callback (JSVal -> IO ()) -> NavigatorUserMediaErrorCallback)
-> (Function -> Callback (JSVal -> IO ()))
-> Function
-> NavigatorUserMediaErrorCallback
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Function -> Callback (JSVal -> IO ())
forall a. Function -> Callback a
Callback (Function -> NavigatorUserMediaErrorCallback)
-> JSM Function -> DOM NavigatorUserMediaErrorCallback
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
         JSCallAsFunction -> JSM Function
asyncFunction
           (\ JSVal
_ JSVal
_ [JSVal
error] ->
              JSVal -> JSM NavigatorUserMediaError
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked JSVal
error JSM NavigatorUserMediaError
-> (NavigatorUserMediaError -> JSM ()) -> JSM ()
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ NavigatorUserMediaError
error' -> NavigatorUserMediaError -> JSM ()
callback NavigatorUserMediaError
error'))