github.com/hernad/nomad@v1.6.112/ui/app/services/watch-list.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  import { computed } from '@ember/object';
     7  import { readOnly } from '@ember/object/computed';
     8  import { copy } from 'ember-copy';
     9  import Service from '@ember/service';
    10  
    11  let list = {};
    12  
    13  export default class WatchListService extends Service {
    14    @computed
    15    get _list() {
    16      return copy(list, true);
    17    }
    18  
    19    @readOnly('_list') list;
    20  
    21    constructor() {
    22      super(...arguments);
    23      list = {};
    24    }
    25  
    26    getIndexFor(url) {
    27      return list[url] || 1;
    28    }
    29  
    30    setIndexFor(url, value) {
    31      list[url] = +value;
    32    }
    33  }