How to use the expo-core.EventEmitter function in expo-core

To help you get started, we’ve selected a few expo-core 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 expo / expo / modules / expo-media-library / src / MediaLibrary.js View on Github external
// @flow

import { Platform } from 'react-native';
import { NativeModulesProxy, EventEmitter } from 'expo-core';

const MediaLibrary = NativeModulesProxy.ExponentMediaLibrary;
const eventEmitter = new EventEmitter(MediaLibrary);

type MediaTypeValue = 'audio' | 'photo' | 'video' | 'unknown';
type SortByKey =
  | 'default'
  | 'id'
  | 'mediaType'
  | 'width'
  | 'height'
  | 'creationTime'
  | 'modificationTime'
  | 'duration';
type SortByValue = [SortByKey, boolean] | SortByKey;

type MediaTypeObject = {
  audio: 'audio',
  photo: 'photo',
github expo / expo / modules / expo-ads-admob / src / AdMobInterstitial.js View on Github external
// @flow

'use strict';

import { NativeModulesProxy, EventEmitter } from 'expo-core';
import { Platform } from 'react-native';
import type { EmitterSubscription } from 'react-native';

const AdMobInterstitialManager: Object = NativeModulesProxy.ExpoAdsAdMobInterstitialManager;

const adMobInterstitialEmitter = new EventEmitter(AdMobInterstitialManager);

const eventNames = [
  'interstitialDidLoad',
  'interstitialDidFailToLoad',
  'interstitialDidOpen',
  'interstitialDidClose',
  'interstitialWillLeaveApplication',
];

type EventNameType =
  | 'interstitialDidLoad'
  | 'interstitialDidFailToLoad'
  | 'interstitialDidOpen'
  | 'interstitialDidClose'
  | 'interstitialWillLeaveApplication';
github expo / expo / modules / expo-location / src / Location.js View on Github external
// @flow

import invariant from 'invariant';
import { NativeModulesProxy, EventEmitter } from 'expo-core';
import { Platform } from 'react-native';

const { ExpoLocation: Location } = NativeModulesProxy;
const LocationEventEmitter = new EventEmitter(Location);

type ProviderStatus = {
  locationServicesEnabled: boolean,
  gpsAvailable: ?boolean,
  networkAvailable: ?boolean,
  passiveAvailable: ?boolean,
};

type LocationOptions = {
  enableHighAccuracy?: boolean,
  timeInterval?: number,
  distanceInterval?: number,
};

type LocationTaskOptions = {
  type: string,
github expo / expo / modules / expo-ads-admob / src / AdMobRewarded.js View on Github external
// @flow

'use strict';

import { NativeModulesProxy, EventEmitter } from 'expo-core';
import { Platform } from 'react-native';

const AdMobRewardedVideoAdManager: Object = NativeModulesProxy.ExpoAdsAdMobRewardedVideoAdManager;

const adMobRewardedEventEmitter = new EventEmitter(AdMobRewardedVideoAdManager);

const eventNames = [
  'rewardedVideoDidRewardUser',
  'rewardedVideoDidLoad',
  'rewardedVideoDidFailToLoad',
  'rewardedVideoDidOpen',
  'rewardedVideoDidStart',
  'rewardedVideoDidClose',
  'rewardedVideoWillLeaveApplication',
];

type EventNameType =
  | 'rewardedVideoDidRewardUser'
  | 'rewardedVideoDidLoad'
  | 'rewardedVideoDidFailToLoad'
  | 'rewardedVideoDidOpen'
github expo / expo / packages / expo-location / src / ExpoLocation.web.ts View on Github external
};

interface PermissionResult {
  status: string,
};

class GeocoderError extends Error {
  code: string;

  constructor() {
    super('Geocoder service is not available for this device.');
    this.code = 'E_NO_GEOCODER';
  }
}

const emitter = new EventEmitter({} as any);

function positionToJSON(position: any): Position | null {
  if (!position) return null;

  const { coords = {}, timestamp } = position;
  return {
    coords: {
      latitude: coords.latitude,
      longitude: coords.longitude,
      altitude: coords.altitude,
      accuracy: coords.accuracy,
      altitudeAccuracy: coords.altitudeAccuracy,
      heading: coords.heading,
      speed: coords.speed,
    },
    timestamp,
github expo / expo / packages / expo-location / src / Location.ts View on Github external
import { EventEmitter, Platform } from 'expo-core';
import invariant from 'invariant';

import ExpoLocation from './ExpoLocation';

const LocationEventEmitter = new EventEmitter(ExpoLocation);

interface ProviderStatus {
  locationServicesEnabled: boolean,
  gpsAvailable?: boolean,
  networkAvailable?: boolean,
  passiveAvailable?: boolean,
};

interface LocationOptions {
  accuracy?: LocationAccuracy,
  enableHighAccuracy?: boolean,
  timeInterval?: number,
  distanceInterval?: number,
  timeout?: number,
};
github expo / expo / packages / expo-location / src / Location.ts View on Github external
import { EventEmitter, Platform } from 'expo-core';
import invariant from 'invariant';

import ExpoLocation from './ExpoLocation';

const LocationEventEmitter = new EventEmitter(ExpoLocation);

interface ProviderStatus {
  locationServicesEnabled: boolean,
  gpsAvailable?: boolean,
  networkAvailable?: boolean,
  passiveAvailable?: boolean,
};

interface LocationOptions {
  accuracy?: LocationAccuracy,
  enableHighAccuracy?: boolean,
  timeInterval?: number,
  distanceInterval?: number,
  timeout?: number,
  mayShowUserSettingsDialog?: boolean,
};
github expo / expo / packages / expo-file-system / src / FileSystem.js View on Github external
constructor(
    url: string,
    fileUri: string,
    options: DownloadOptions = {},
    callback: ?DownloadProgressCallback,
    resumeData: ?string
  ) {
    this._uuid = UUID.create(4).toString();
    this._url = url;
    this._fileUri = fileUri;
    this._options = options;
    this._resumeData = resumeData;
    this._callback = callback;
    this._subscription = null;
    this._emitter = new EventEmitter(FS);
  }
github expo / expo / modules / expo-file-system / FileSystem.js View on Github external
constructor(
    url: string,
    fileUri: string,
    options: DownloadOptions = {},
    callback: ?DownloadProgressCallback,
    resumeData: ?string
  ) {
    this._uuid = UUID.create(4).toString();
    this._url = url;
    this._fileUri = fileUri;
    this._options = options;
    this._resumeData = resumeData;
    this._callback = callback;
    this._subscription = null;
    this._emitter = new EventEmitter(FS);
  }