How to use the tiny-emitter/instance.on function in tiny-emitter

To help you get started, we’ve selected a few tiny-emitter 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 syousif94 / frugalmaps / frugalapp / src / CalendarMap.js View on Github external
componentDidMount() {
    emitter.on("fit-bounds", this._fitBounds);
    // emitter.on("fit-marker", this._fitMarker);
    // emitter.on("reset-marker", this._resetMarker);
  }
github syousif94 / frugalmaps / frugalapp / src / InfoScreen.js View on Github external
this.props.fetch({
        id
      });
    }

    this._loadingTimeout = setTimeout(() => {
      this.setState({
        loading: false
      });
    }, 150);

    // if (IOS) {
    //   StatusBar.setBarStyle("light-content");
    // }

    emitter.on(InfoScreen.mapId, this._showLocation);
  }
github syousif94 / frugalmaps / buncha / screens / UpNextScreen.js View on Github external
useEffect(() => {
    const dismissFilters = () => {
      emitter.emit("filters");
    };
    const onEvent = () => {
      if (IOS) {
        initialLoadCompleted.current = false;
        requestAnimationFrame(dismissFilters);
      } else if (ANDROID) {
        requestAnimationFrame(dismissFilters);
      } else if (WEB) {
        requestAnimationFrame(dismissFilters);
      }
    };

    emitter.on("refresh", onEvent);

    return () => {
      emitter.off("refresh", onEvent);
    };
  }, []);
github syousif94 / frugalmaps / frugalapp / src / LocationLists.js View on Github external
componentDidMount() {
    emitter.on("preview-bounds", this._previewBounds);
    emitter.on("reset-bounds-preview", this._resetRegion);

    const show = IOS ? "keyboardWillShow" : "keyboardDidShow";
    this.keyboardWillShowListener = Keyboard.addListener(
      show,
      this._keyboardWillShow
    );

    if (ANDROID) {
      const hide = IOS ? "keyboardWillHide" : "keyboardDidHide";
      this.keyboardWillHideListener = Keyboard.addListener(
        hide,
        this._keyboardWillHide
      );
    }
  }
github syousif94 / frugalmaps / frugalapp / src / Menu.js View on Github external
componentDidMount() {
    emitter.on("toggle-menu", this._toggleMenu);
    emitter.on("toggle-search", this._toggleSearch);
    emitter.on("info-pop", this._onInfoPop);
    if (ANDROID) {
      this.keyboardWillHideListener = Keyboard.addListener(
        "keyboardDidHide",
        this._keyboardWillHide
      );
    }
  }
github syousif94 / frugalmaps / buncha / components / InterestedModal.js View on Github external
e.preventDefault();
    };
    const onFocus = () => {
      inputRef.current.focus();
      if (WEB) {
        window.addEventListener("mousedown", onMouseDown);
      }
    };
    const onBlur = () => {
      inputRef.current.blur();
      if (WEB) {
        window.removeEventListener("mousedown", onMouseDown);
      }
    };

    emitter.on("focus-interested", onFocus);
    emitter.on("blur-interested", onBlur);

    return () => {
      emitter.off("focus-interested", onFocus);
      emitter.off("blur-interested", onBlur);
    };
  }, []);
github forest-watcher / forest-watcher / app / components / map / index.js View on Github external
componentDidMount() {
    BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
    AppState.addEventListener('change', this.handleAppStateChange);

    tracker.trackScreenView('Map');

    emitter.on(GFWOnHeadingEvent, this.updateHeading);
    emitter.on(GFWOnLocationEvent, this.updateLocationFromGeolocation);

    this.geoLocate();

    this.staleLocationTimer = setInterval(() => {
      this.setState(state => {
        if (
          !state.locationError &&
          state.location &&
          Date.now() - state.location.timestamp > STALE_LOCATION_THRESHOLD
        ) {
          return {
            locationError: GFWErrorLocationStale
          };
        }
        return {};
      });
github syousif94 / frugalmaps / frugalapp / src / LocationLists.js View on Github external
componentDidMount() {
    emitter.on("preview-bounds", this._previewBounds);
    emitter.on("reset-bounds-preview", this._resetRegion);

    const show = IOS ? "keyboardWillShow" : "keyboardDidShow";
    this.keyboardWillShowListener = Keyboard.addListener(
      show,
      this._keyboardWillShow
    );

    if (ANDROID) {
      const hide = IOS ? "keyboardWillHide" : "keyboardDidHide";
      this.keyboardWillHideListener = Keyboard.addListener(
        hide,
        this._keyboardWillHide
      );
    }
  }
github syousif94 / frugalmaps / frugalapp / src / CalendarDayList.js View on Github external
componentDidMount() {
    emitter.on("calendar-top", this._scrollToTop);
    if (IOS) {
      emitter.on("reclip-calendar", this._reclip);
    }
  }
github syousif94 / frugalmaps / frugalapp / src / MapMarker.ios.js View on Github external
componentDidMount() {
    emitter.on("fit-marker", this._fitMarker);
    emitter.on("hide-callouts", this._hideCallout);
  }

tiny-emitter

A tiny (less than 1k) event emitter library

MIT
Latest version published 6 years ago

Package Health Score

67 / 100
Full package analysis