How to use time-sync - 6 common examples

To help you get started, we’ve selected a few time-sync 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 peterjuras / react-time-sync / src / context.ts View on Github external
import React from "react";
import TimeSync from "time-sync";

export const TIMESYNC_PROP = "$$_TIME_SYNC_HIDDEN_$$";

export interface TimeSyncContext {
  getCurrentTime: typeof TimeSync.getCurrentTime;
  getTimeLeft: typeof TimeSync.getTimeLeft;
  addTimer: typeof TimeSync.prototype.addTimer;
  createCountdown: typeof TimeSync.prototype.createCountdown;
}

const timeSync = new TimeSync();

export default React.createContext({
  getCurrentTime: TimeSync.getCurrentTime,
  getTimeLeft: TimeSync.getTimeLeft,
  addTimer: timeSync.addTimer,
  createCountdown: timeSync.createCountdown
});
github peterjuras / react-time-sync / src / time-provider.tsx View on Github external
public constructor(props: TimeProviderProps) {
    super(props);

    const timeSync = props.timeSync || new TimeSync();
    this.state = {
      timeSync,
      customTimeSync: !!props.timeSync,
      timeContext: {
        getCurrentTime: TimeSync.getCurrentTime,
        getTimeLeft: TimeSync.getTimeLeft,
        addTimer: timeSync.addTimer,
        createCountdown: timeSync.createCountdown
      }
    };
  }
github peterjuras / react-time-sync / src / time-provider.tsx View on Github external
public constructor(props: TimeProviderProps) {
    super(props);

    const timeSync = props.timeSync || new TimeSync();
    this.state = {
      timeSync,
      customTimeSync: !!props.timeSync,
      timeContext: {
        getCurrentTime: TimeSync.getCurrentTime,
        getTimeLeft: TimeSync.getTimeLeft,
        addTimer: timeSync.addTimer,
        createCountdown: timeSync.createCountdown
      }
    };
  }
github peterjuras / react-time-sync / src / context.ts View on Github external
import React from "react";
import TimeSync from "time-sync";

export const TIMESYNC_PROP = "$$_TIME_SYNC_HIDDEN_$$";

export interface TimeSyncContext {
  getCurrentTime: typeof TimeSync.getCurrentTime;
  getTimeLeft: typeof TimeSync.getTimeLeft;
  addTimer: typeof TimeSync.prototype.addTimer;
  createCountdown: typeof TimeSync.prototype.createCountdown;
}

const timeSync = new TimeSync();

export default React.createContext({
  getCurrentTime: TimeSync.getCurrentTime,
  getTimeLeft: TimeSync.getTimeLeft,
  addTimer: timeSync.addTimer,
  createCountdown: timeSync.createCountdown
});
github peterjuras / react-time-sync / src / context.ts View on Github external
import TimeSync from "time-sync";

export const TIMESYNC_PROP = "$$_TIME_SYNC_HIDDEN_$$";

export interface TimeSyncContext {
  getCurrentTime: typeof TimeSync.getCurrentTime;
  getTimeLeft: typeof TimeSync.getTimeLeft;
  addTimer: typeof TimeSync.prototype.addTimer;
  createCountdown: typeof TimeSync.prototype.createCountdown;
}

const timeSync = new TimeSync();

export default React.createContext({
  getCurrentTime: TimeSync.getCurrentTime,
  getTimeLeft: TimeSync.getTimeLeft,
  addTimer: timeSync.addTimer,
  createCountdown: timeSync.createCountdown
});
github peterjuras / react-time-sync / src / time-provider.tsx View on Github external
public constructor(props: TimeProviderProps) {
    super(props);

    const timeSync = props.timeSync || new TimeSync();
    this.state = {
      timeSync,
      customTimeSync: !!props.timeSync,
      timeContext: {
        getCurrentTime: TimeSync.getCurrentTime,
        getTimeLeft: TimeSync.getTimeLeft,
        addTimer: timeSync.addTimer,
        createCountdown: timeSync.createCountdown
      }
    };
  }

time-sync

A JavaScript library to synchronize timers across an application

MIT
Latest version published 3 years ago

Package Health Score

52 / 100
Full package analysis

Similar packages