I'm building an application in Ember.js and I'm having an issue monitoring a property I'm displaying to the user. When the user logs in I'm querying an API to get the count of the number of message that have a field called "isTrue" and seeing how many have a value of "true".
When the user logs into the system I am grabbing an ID from their cookie in the application controller through the init: function()
This data is then being displayed in the Application Template. Is this the best way to do this? I'm having an issue that when the user clicks on a button to change the record from "isNew" == "true" to "isNew" == "false" the property is not updating correctly. Is this the best way to do this or am I going about it all wrong from an Ember standpoint?
App.ApplicationController = Ember.Controller.extend({
messageCount: null,
init: function() {
var test = 0;
//get the cookie
//query an API to retrieve a set of records to check if a specific field is marked as true
//Compute the messageCount based on the number of records that are marked as true and set test equal to the message count.
this.set("messageCount", test);
getMessages: function() {
//repeat the code from the init function
}
actions: {
markAsRead: function() {
getMessages();
}
}
})