mardi 7 mai 2019

emberjs: how to get id and update the model data

I have two components items and item-list.

my item route is:

this.route('items', function() {
  this.route('items', { path: '/:item_id' });
});

In my Items list when clicked to one of the items it takes to those items with a specific team_id.


  <div class="items-list" >
     
  </div>


In my Item component, I wrote a task which will run every minute to get the data of that item.

I am new to emberjs, I don't know how to update the model data. I am trying to get the data using store.findAll() will this update the model data and how to get the id of the current item to pass it in store.findAll()

  didInsertElement() {
    this._super(...arguments);

    this._startPolling();
  },

  _startPolling() {
    this.__poll_id = this.poll.addPoll({
      interval: 1000 * 60,
      callback: this.updateTask.bind(this)
    });
  },

  updateTask() {
    this._updateItem.perform();
  },

  _updateItem: task(function* updateItem() {
     /* how to pass current item id and will this update the model*/
    let data = yield this.store.findAll(`/items/:id`);
  }).restartable(),

  willDestroyElement() {
    this._super(...arguments);

    this.poll.clearPoll(this.__poll_id);
  }




Aucun commentaire:

Enregistrer un commentaire