How to use the signals.Signal function in signals

To help you get started, we’ve selected a few signals 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 arose / ngl / src / stage / mouse-observer.ts View on Github external
* @example
 * // listen to double clicking (and double tapping) events
 * mouseObserver.signals.doubleClicked.add( function(){ ... } );
 *
 * @example
 * // listen to hovering events
 * mouseObserver.signals.hovered.add( function(){ ... } );
 */
class MouseObserver {
  signals: MouseSignals = {
    moved: new Signal(),
    scrolled: new Signal(),
    dragged: new Signal(),
    dropped: new Signal(),
    clicked: new Signal(),
    hovered: new Signal(),
    doubleClicked: new Signal()
  }

  hoverTimeout: number
  handleScroll:boolean
  doubleClickSpeed: number

  viewer: Viewer
  mouse: MouseObserver
  controls: MouseControls

  position = new Vector2()  // Position on page
  prevPosition = new Vector2()  // Previous position on page
  down = new Vector2()  // Position on page when clicked
  canvasPosition = new Vector2()  // Position on dom element
  prevClickCP = new Vector2()
github arose / ngl / src / component / component.ts View on Github external
representationRemoved: Signal  // when a representation is removed
  visibilityChanged: Signal  // on matrix change
  matrixChanged: Signal  // on visibility change
  statusChanged: Signal  // on status change
  nameChanged: Signal  // on name change
  disposed: Signal  // on dispose
}

/**
 * Base class for components
 */
abstract class Component {
  signals: ComponentSignals = {
    representationAdded: new Signal(),
    representationRemoved: new Signal(),
    visibilityChanged: new Signal(),
    matrixChanged: new Signal(),
    statusChanged: new Signal(),
    nameChanged: new Signal(),
    disposed: new Signal()
  }

  parameters: ComponentParameters
  get defaultParameters () { return ComponentDefaultParameters }

  uuid: string
  status: string
  stage: Stage
  viewer: Viewer

  reprList: RepresentationElement[] = []
  annotationList: Annotation[] = []
github arose / ngl / src / stage / mouse-observer.ts View on Github external
* // listen to double clicking (and double tapping) events
 * mouseObserver.signals.doubleClicked.add( function(){ ... } );
 *
 * @example
 * // listen to hovering events
 * mouseObserver.signals.hovered.add( function(){ ... } );
 */
class MouseObserver {
  signals: MouseSignals = {
    moved: new Signal(),
    scrolled: new Signal(),
    dragged: new Signal(),
    dropped: new Signal(),
    clicked: new Signal(),
    hovered: new Signal(),
    doubleClicked: new Signal()
  }

  hoverTimeout: number
  handleScroll:boolean
  doubleClickSpeed: number

  viewer: Viewer
  mouse: MouseObserver
  controls: MouseControls

  position = new Vector2()  // Position on page
  prevPosition = new Vector2()  // Previous position on page
  down = new Vector2()  // Position on page when clicked
  canvasPosition = new Vector2()  // Position on dom element
  prevClickCP = new Vector2()
github arose / ngl / src / component / component.ts View on Github external
matrixChanged: Signal  // on visibility change
  statusChanged: Signal  // on status change
  nameChanged: Signal  // on name change
  disposed: Signal  // on dispose
}

/**
 * Base class for components
 */
abstract class Component {
  signals: ComponentSignals = {
    representationAdded: new Signal(),
    representationRemoved: new Signal(),
    visibilityChanged: new Signal(),
    matrixChanged: new Signal(),
    statusChanged: new Signal(),
    nameChanged: new Signal(),
    disposed: new Signal()
  }

  parameters: ComponentParameters
  get defaultParameters () { return ComponentDefaultParameters }

  uuid: string
  status: string
  stage: Stage
  viewer: Viewer

  reprList: RepresentationElement[] = []
  annotationList: Annotation[] = []

  matrix = new Matrix4()
github arose / ngl / src / component / trajectory-element.ts View on Github external
constructor (stage: Stage, readonly trajectory: Trajectory, params: Partial = {}) {
    super(stage, Object.assign({ name: trajectory.name }, params))

    this.signals = Object.assign(this.signals, {
      frameChanged: new Signal(),
      playerChanged: new Signal(),
      countChanged: new Signal(),
      parametersChanged: new Signal()
    })

    // signals

    trajectory.signals.frameChanged.add((i: number) => {
      this.signals.frameChanged.dispatch(i)
    })

    trajectory.signals.playerChanged.add((player: TrajectoryPlayer) => {
      this.signals.playerChanged.dispatch(player)
    })

    trajectory.signals.countChanged.add((n: number) => {
github arose / ngl / src / component / trajectory-element.ts View on Github external
constructor (stage: Stage, readonly trajectory: Trajectory, params: Partial = {}) {
    super(stage, Object.assign({ name: trajectory.name }, params))

    this.signals = Object.assign(this.signals, {
      frameChanged: new Signal(),
      playerChanged: new Signal(),
      countChanged: new Signal(),
      parametersChanged: new Signal()
    })

    // signals

    trajectory.signals.frameChanged.add((i: number) => {
      this.signals.frameChanged.dispatch(i)
    })

    trajectory.signals.playerChanged.add((player: TrajectoryPlayer) => {
      this.signals.playerChanged.dispatch(player)
    })

    trajectory.signals.countChanged.add((n: number) => {
      this.signals.countChanged.dispatch(n)
    })
github millermedeiros / crossroads.js / dist / crossroads.cjs.js View on Github external
function Route(pattern, callback, priority, router){
        var isRegexPattern = isRegExp(pattern);
        this._router = router;
        this._pattern = pattern;
        this._paramsIds = isRegexPattern? null : patternLexer.getParamIds(this._pattern);
        this._optionalParamsIds = isRegexPattern? null : patternLexer.getOptionalParamsIds(this._pattern);
        this._matchRegexp = isRegexPattern? pattern : patternLexer.compilePattern(pattern);
        this.matched = new signals.Signal();
        if(callback) this.matched.add(callback);
        this._priority = priority || 0;
    }
github millermedeiros / crossroads.js / dist / crossroads.cjs.js View on Github external
function Crossroads(){
        this._routes = [];
        this.bypassed = new signals.Signal();
        this.routed = new signals.Signal();
    }
github millermedeiros / crossroads.js / dist / crossroads.cjs.js View on Github external
function Crossroads(){
        this._routes = [];
        this.bypassed = new signals.Signal();
        this.routed = new signals.Signal();
    }
github FredrikNoren / ungit / source / git-task.js View on Github external
var GitTask = function() {
  var self = this;
  this._completed = false;
  this._started = false;
  this.onDone = new signals.Signal();
  this.onFail = new signals.Signal();
  this.onStarted = new signals.Signal();
  this.always = function(callback) {
    if (self._completed) callback(self.error, self.result);
    else {
      self.onDone.add(callback.bind(null, null));
      self.onFail.add(callback);
    }
    return self;
  }
  this.done = function(callback) {
    if (self._completed) {
      if (!self.error) callback(self.result);
    }
    else self.onDone.add(callback);
    return self;
  }
  this.fail = function(callback) {

signals

Custom Event/Messaging System

Unknown
Latest version published 12 years ago

Package Health Score

50 / 100
Full package analysis

Popular signals functions