How to use the event-target-shim function in event-target-shim

To help you get started, we’ve selected a few event-target-shim examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github react-native-webrtc / react-native-webrtc / MediaDevices.js View on Github external
'use strict';

import {NativeModules} from 'react-native';
import EventTarget from 'event-target-shim';

import getUserMedia from './getUserMedia';

const {WebRTCModule} = NativeModules;

const MEDIA_DEVICES_EVENTS = [
    'devicechange'
];

class MediaDevices extends EventTarget(MEDIA_DEVICES_EVENTS) {
    // TODO: implement.
    ondevicechange: ?Function;

    /**
     * W3C "Media Capture and Streams" compatible {@code enumerateDevices}
     * implementation.
     */
    enumerateDevices() {
        return new Promise(resolve => WebRTCModule.enumerateDevices(resolve));
    }

    /**
     * W3C "Media Capture and Streams" compatible {@code getUserMedia}
     * implementation.
     * See: https://www.w3.org/TR/mediacapture-streams/#dom-mediadevices-enumeratedevices
     *
github react-native-webrtc / react-native-webrtc / RTCDataChannel.js View on Github external
'connecting' |
  'open' |
  'closing' |
  'closed';

const DATA_CHANNEL_EVENTS = [
  'open',
  'message',
  'bufferedamountlow',
  'close',
  'error',
];

class ResourceInUse extends Error {}

export default class RTCDataChannel extends EventTarget(DATA_CHANNEL_EVENTS) {

  _peerConnectionId: number;

  binaryType: 'arraybuffer' = 'arraybuffer'; // we only support 'arraybuffer'
  bufferedAmount: number = 0;
  bufferedAmountLowThreshold: number = 0;
  id: number;
  label: string;
  maxPacketLifeTime: ?number = null;
  maxRetransmits: ?number = null;
  negotiated: boolean = false;
  ordered: boolean = true;
  protocol: string = '';
  readyState: RTCDataChannelState = 'connecting';

  onopen: ?Function;
github react-native-webrtc / react-native-webrtc / MediaStreamTrack.js View on Github external
'mute',
  'unmute',
  // see: https://www.w3.org/TR/mediacapture-streams/#constrainable-interface
  'overconstrained',
];

type MediaStreamTrackState = "live" | "ended";

type SourceInfo = {
  id: string;
  label: string;
  facing: string;
  kind: string;
};

class MediaStreamTrack extends EventTarget(MEDIA_STREAM_TRACK_EVENTS) {
  _enabled: boolean;
  id: string;
  kind: string;
  label: string;
  muted: boolean;
  readonly: boolean; // how to decide?
  // readyState in java: INITIALIZING, LIVE, ENDED, FAILED
  readyState: MediaStreamTrackState;
  remote: boolean;

  onended: ?Function;
  onmute: ?Function;
  onunmute: ?Function;
  overconstrained: ?Function;

  constructor(info) {
github react-native-webrtc / react-native-webrtc / RTCPeerConnection.js View on Github external
'icecandidate',
  'icecandidateerror',
  'iceconnectionstatechange',
  'icegatheringstatechange',
  'negotiationneeded',
  'signalingstatechange',
  // Peer-to-peer Data API:
  'datachannel',
  // old:
  'addstream',
  'removestream',
];

let nextPeerConnectionId = 0;

export default class RTCPeerConnection extends EventTarget(PEER_CONNECTION_EVENTS) {
  localDescription: RTCSessionDescription;
  remoteDescription: RTCSessionDescription;

  signalingState: RTCSignalingState = 'stable';
  iceGatheringState: RTCIceGatheringState = 'new';
  iceConnectionState: RTCIceConnectionState = 'new';

  onconnectionstatechange: ?Function;
  onicecandidate: ?Function;
  onicecandidateerror: ?Function;
  oniceconnectionstatechange: ?Function;
  onicegatheringstatechange: ?Function;
  onnegotiationneeded: ?Function;
  onsignalingstatechange: ?Function;

  onaddstream: ?Function;
github react-native-webrtc / react-native-webrtc / MediaStream.js View on Github external
import {NativeModules} from 'react-native';
import EventTarget from 'event-target-shim';
import uuid from 'uuid';

import MediaStreamTrack from './MediaStreamTrack';

const {WebRTCModule} = NativeModules;

const MEDIA_STREAM_EVENTS = [
  'active',
  'inactive',
  'addtrack',
  'removetrack',
];

export default class MediaStream extends EventTarget(MEDIA_STREAM_EVENTS) {
  id: string;
  active: boolean = true;

  onactive: ?Function;
  oninactive: ?Function;
  onaddtrack: ?Function;
  onremovetrack: ?Function;

  _tracks: Array = [];

  /**
   * The identifier of this MediaStream unique within the associated
   * WebRTCModule instance. As the id of a remote MediaStream instance is unique
   * only within the associated RTCPeerConnection, it is not sufficiently unique
   * to identify this MediaStream across multiple RTCPeerConnections and to
   * unambiguously differentiate it from a local MediaStream instance not added
github shiguredo / react-native-webrtc-kit / src / PeerConnection / RTCPeerConnectionEventTarget.js View on Github external
'icecandidate',
  'iceconnectionstatechange',
  'icegatheringstatechange',
  'identityresult',
  'idpassertionerror',
  'idpvalidationerror',
  'negotiationneeded',
  'peeridentity',
  'signalingstatechange',
  'track',
];

/**
 * @package
 */
export default class RTCPeerConnectionEventTarget extends EventTarget(PEER_CONNECTION_EVENTS) { }

event-target-shim

An implementation of WHATWG EventTarget interface.

MIT
Latest version published 3 years ago

Package Health Score

70 / 100
Full package analysis