Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/francy/js/packages/francy-core/src/util/   (Algebra von RWTH Aachen Version 4.15.1©)  Datei vom 17.3.2023 mit Größe 1 kB image not shown  

Quelle  observable.js   Sprache: JAVA

 
import {Utilities} from './utilities';

/**
 * This {Observable} class implements the Observer Pattern.
 */

export default class Observable {
  /**
   * Creates an instance of Observable.
   */

  constructor() {
    /**
     * This is property holds an object of change subscribers.
     * @type {object}
     * @private
     */

    this._subscribers = {};
  }

  /**
   * This method is used register a function that is invoked to sync the object
   * @param {string} property - the property to subscribe to
   * @param {function} fn - the function to execute - must handle one arg, the object, of type {Object}
   * @param {string} id - the id of the subscriber
   * @public
   */

  subscribe(property, fn, id) {
    if (!id) {
      throw new Error('ID is mandatory');
    }
    this._subscribers[id] = {property: property, fn: fn};
  }

  /**
   * This method is used to unregister a function registered previously
   * @param {string} id - the id of the subscriber
   * @public
   */

  unsubscribe(id) {
    if (!id) {
      throw new Error('ID is mandatory');
    }
    delete this._subscribers[id];
  }

  /**
   * This method is used to unregister all functions registered previously
   * @public
   */

  unsubscribeAll() {
    this._subscribers = {};
  }

  /**
   * This method is used to notify all subscribers of a change
   * @param {string} property - the property to notify subscribers
   * @param {Object} value - the value that changed
   * @public
   */

  notify(property, value) {
    Object.values(this._subscribers).forEach(s =>
      Utilities.isEqual(s.property, property) && s.fn.call(this, value));
  }

}

Messung V0.5
C=89 H=92 G=90

¤ Dauer der Verarbeitung: 0.2 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.