How to use the @swim/structure.Value.absent function in @swim/structure

To help you get started, we’ve selected a few @swim/structure 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 swimos / swim / swim-js / swim-core-js / @swim / client / main / downlink / ListDownlinkModel.ts View on Github external
protected onUpdateEvent(index: number, newValue: Value, key: Value): void {
    newValue = this.listWillUpdate(index, newValue);
    const oldValue = this._state.get(index) || Value.absent();
    this._state.set(index, newValue);
    this.listDidUpdate(index, newValue, oldValue);
  }
github swimos / swim / swim-js / swim-core-js / @swim / client / main / downlink / ListDownlinkModel.ts View on Github external
insert(index: number, newValue: Value, key?: Value): this {
    if (index < 0 || index > this._state.length) {
      throw new RangeError("" + index);
    }
    newValue = this.listWillUpdate(index, newValue);
    this._state.insert(index, newValue, key);
    const newEntry = this._state.getEntry(index)!;
    this.listDidUpdate(index, newValue, Value.absent());
    const header = Record.create(2).slot("key", newEntry[0]).slot("index", index);
    this.command(Attr.of("update", header).concat(newValue));
    return this;
  }
github swimos / swim / swim-js / swim-core-js / @swim / client / main / downlink / ListDownlinkModel.ts View on Github external
protected onMoveEvent(fromIndex: number, toIndex: number, key: Value): void {
    toIndex = Math.min(Math.max(0, toIndex), this._state.length);
    if (fromIndex !== toIndex) {
      const value = this._state.get(fromIndex) || Value.absent();
      this.listWillMove(fromIndex, toIndex, value);
      this._state.remove(fromIndex).insert(toIndex, value, key);
      this.listDidMove(fromIndex, toIndex, value);
    }
  }
github swimos / swim / swim-js / swim-core-js / @swim / client / main / downlink / ListDownlinkModel.ts View on Github external
protected onInsertEvent(index: number, newValue: Value, key: Value): void {
    newValue = this.listWillUpdate(index, newValue);
    this._state.insert(index, newValue, key);
    this.listDidUpdate(index, newValue, Value.absent());
  }
github swimos / swim / swim-js / swim-core-js / @swim / client / main / downlink / ListDownlinkModel.ts View on Github external
get(index: number, key?: Value): Value {
    return this._state.get(index, key) || Value.absent();
  }
github swimos / swim / swim-js / swim-core-js / @swim / client / main / downlink / ListDownlinkModel.ts View on Github external
unshift(...newValues: Value[]): number {
    for (let i = newValues.length - 1; i >= 0; i -= 1) {
      const newValue = this.listWillUpdate(0, newValues[i]);
      this._state.insert(0, newValue);
      const newEntry = this._state.getEntry(0)!;
      this.listDidUpdate(0, newValue, Value.absent());
      const header = Record.create(2).slot("key", newEntry[0]).slot("index", 0);
      this.command(Attr.of("update", header).concat(newValue));
    }
    return this._state.length;
  }
github swimos / swim / swim-js / swim-core-js / @swim / client / main / downlink / ListDownlinkModel.ts View on Github external
protected onRemoveEvent(index: number, key: Value): void {
    this.listWillRemove(index);
    const oldValue = this._state.get(index) || Value.absent();
    this._state.remove(index);
    this.listDidRemove(index, oldValue);
  }
github swimos / swim / swim-js / swim-core-js / @swim / client / main / downlink / ListDownlinkModel.ts View on Github external
pop(): Value {
    const index = this._state.length - 1;
    if (index >= 0) {
      this.listWillRemove(index);
      const oldEntry = this._state.getEntry(index)!;
      this._state.remove(index);
      this.listDidRemove(index, oldEntry[1]);
      const header = Record.create(2).slot("key", oldEntry[0]).slot("index", index);
      this.command(Record.create(1).attr("remove", header));
      return oldEntry[1];
    } else {
      return Value.absent();
    }
  }