14795

Is there a way to set an observer on any ember model change in ember store?

First of all, I am using ember 2. I am requesting the back-end and it returns some data. Then, I pushed these data to a model in ember store. The issue that I want to do some action when this model is updated. So, Is there a way to observe the model in the store? Thank you in advance.

Answer1:

findAll returns live array, so we can have dependent key for the findAll result so that our observer/computed properties will be triggered every time stores model changes.

userModel:Ember.computed(function() { return this.get('store').findAll('user'); }), userModelObserver: Ember.observer('userModel.[]',function(){ console.log('observer triggered'); }),

May be this is not the ideal solution.

Recommend

  • android 2.2 WebView and WebViewClient RTSP problem
  • SecurityError for same-origin image texImage2D
  • Fixed positioned elements disappear on page unload
  • How can I install and use latest Git on Mac OS X 10.9?
  • Boost Spirit Qi Attribute Propagation
  • Git subtree post hook
  • How does CoreLocation locate the device?
  • How to create a data template dependent on an XML Attribute?
  • C# COM Component Fails To Read Config When Loaded Into An Unmanaged C++ App
  • How do I recognize a line break with a switch case that evaluates a char in Java?
  • Bootstrap Popover showing at wrong place upon zoom in/out or resizing Browser window
  • Hibernate Joda DateTime Sorting
  • How to change the default configuration files used in bootstrapping of reactJs through npm
  • how to get data attributes of dynamically generated element
  • BeautifulSoup difference between findAll and findChildren
  • Jquery Knockout: ko.computed() vs classic function?
  • Bootstrap (v3.3.4) glyphicons not displayed in IE when refresh page (F5)
  • JPA flush vs commit
  • Implementing “partial void” in VB
  • Sending HTML Form Data to Spring REST Web Service
  • Position: fixed nav does not stay fixed
  • How to revert to previous XCode version?
  • Handling un-mapped Rest path
  • PHPUnit_Framework_TestCase class is not available. Fix… - Makegood , Eclipse
  • Display issues when we change from one jquery mobile page to another in firefox
  • Different response to non-authenticated users and AJAX calls
  • Date difference with leap year
  • recyclerView does not call the onBindViewHolder when scroll in the view
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • what is the difference between the asp.net mvc application and asp.net web application
  • Web-crawler for facebook in python
  • How to get next/previous record number?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • R: gsub and capture
  • Confusion with PayPal's monthly billing cycle
  • Data Validation Drop Down Box Arrow Disappearing
  • Benchmarking RAM performance - UWP and C#
  • Angular 2 constructor injection vs direct access
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Net Present Value in Excel for Grouped Recurring CF