0

Diff between currentAppData and messages.store

Hi,
Can somebody explain to me what is the difference betwwen currentAppData and messages.store? When to use them and what is the maximum amount of data we can store or pass using them.

Thanks
Priya

by
7 Replies
  • currentAppData is a permanent storage area that persists between power cycles.

    messages.store is a temporary storage area that only exists during run time and is cleared during power cycle.

    For Example:
    CODE
    //Turn TV on
    var temp = messages.store("my_info","Data Saved During Last Widget Use");
    var perm = currentAppData.set("my_info","Data Saved During Last Widget Use");

    //power cycle TV
    var temp = messages.fetch("my_info");
    var perm = currentAppData.get("my_info");
    print(temp); // = false
    print(perm); // = "Data Saved During Last Widget Use"

    //Now set the my_info messages
    messages.store("my_info",perm);

    //Check the run time data
    var temp = messages.fetch("my_info");
    var perm = currentAppData.get("my_info");
    print(temp); // = "Data Saved During Last Widget Use"
    print(perm); // = "Data Saved During Last Widget Use"
    0
  • I tried using this but every time it sayd messages is not defined and don't have properties. do i have to include some other file to get to view this?
    0
  • This is any example if you run the code in it's full version it will not do anything...

    Include your code - in code tags - then we will be able to actually see the problem - instead of guessing at your issues.
    0
  • Misread your post. Here is the fixed source.

    CODE
    //Turn TV on
    var temp = KONtx.messages.store("my_info","Data Saved During Last Widget Use");
    var perm = currentAppData.set("my_info","Data Saved During Last Widget Use");

    //power cycle TV
    var temp = KONtx.messages.fetch("my_info");
    var perm = currentAppData.get("my_info");
    print(temp); // = false
    print(perm); // = "Data Saved During Last Widget Use"

    //Now set the my_info messages
    KONtx.messages.store("my_info",perm);

    //Check the run time data
    var temp = KONtx.messages.fetch("my_info");
    var perm = currentAppData.get("my_info");
    print(temp); // = "Data Saved During Last Widget Use"
    print(perm); // = "Data Saved During Last Widget Use"
    0
  • QUOTE (ganeshkumar @ Oct 26 2010, 05:58 PM) <{POST_SNAPBACK}>
    Hi,
    Can somebody explain to me what is the difference betwwen currentAppData and messages.store? When to use them and what is the maximum amount of data we can store or pass using them.

    Thanks
    Priya

    Hi Priya,
    In addition, the great thing about using the message center is that it broadcasts an event whenever data is stored in it. So, if you have a view that is expecting data from a fetch, you can store the results of that fetch in the message center and the view will then know when it was retrieved and stored and be able to do what it needs.

    For example, I often do this in my views to know when I can store data in a grid:

    CODE
    //code snipped for brevity;

    initView: function () {
    this.registerMessageCenterListenerCallback(this._dispatcher);
    },

    _dispatcher: function (event) {
    if (event.type === KONtx.messages.eventType && event.payload.key === "newsItems") {
    this.controls.grid.changeDataset(event.payload.value.dataset);
    }
    }


    - Ben
    0
  • QUOTE (Benjamin Toll @ Oct 28 2010, 01:31 PM) <{POST_SNAPBACK}>
    Hi Priya,
    In addition, the great thing about using the message center is that it broadcasts an event whenever data is stored in it. So, if you have a view that is expecting data from a fetch, you can store the results of that fetch in the message center and the view will then know when it was retrieved and stored and be able to do what it needs.

    For example, I often do this in my views to know when I can store data in a grid:

    CODE
    //code snipped for brevity;

    initView: function () {
    this.registerMessageCenterListenerCallback(this._dispatcher);
    },

    _dispatcher: function (event) {
    if (event.type === KONtx.messages.eventType && event.payload.key === "newsItems") {
    this.controls.grid.changeDataset(event.payload.value.dataset);
    }
    }


    - Ben


    Thanks Everybody.
    Now we have a lear idea about messages.store and currentAppData,but still wondering the permitted amount of data that can be stored in them.

    Priya
    Divya
    0
  • QUOTE (ganeshkumar @ Oct 28 2010, 05:43 PM) <{POST_SNAPBACK}>
    Thanks Everybody.
    Now we have a lear idea about messages.store and currentAppData,but still wondering the permitted amount of data that can be stored in them.

    Priya
    Divya

    Sorry, I didn't see this question.

    Basically, you really don't want to store more than key:value strings in currentAppData, as the dock will closely monitor this. As far as the message center, I'm not aware of a hard rule for the maximum size. The fact that you're asking it makes me think that anything sizeable you have should be stored on the server :)- Ben
    0

Recent Posts

in Getting Started / Beginners - Yahoo! TV Widgets