enyo.Store.find() and a RESTfull backend

edited October 2013 in Enyo 2.4
I have problem with an enyo.Store.find(...). As you mentioned in the doc for this method:
There is a special use for this method if an _euid_ or _primaryKey_ value is provided, the
_euid_ directly on the options hash and the _primaryKey_ value in the _attributes_ hash of the
options. It will attempt to find the record locally first, and if found, call the
_success_ method without using the _source_. If it cannot be found, it will continue normally.
Whether the _source_ is used or not, in a case where the _euid_ or _primaryKey_ value are provided
the result will be a single _record_ or _undefined_, not an array.
The behavior described above is problematic in my case and forces me to overwrite this method in a subkind (or I misunderstood something).

I'm building an Enyo mobile app with RESTfull backend. The application's data is stored locally and remotely, and the mobile app always needs to have the fresh copy of the data. If I run my app on two mobile devices in the same time, the second devices hasn't any chance to find the updates stored by the first device on the remote backend. The enyo.Store.find(...) on second device will return older data pointed by primaryKey without using the _source_ to get fresher data. The same problem will occur if I will persist the local data in the window.localstore: after the first call of enyo.Store.find method the persisted primaryKey will be fetched and the next calls will never use _source_ to find the data in the backend.

How to solve my issue without subclassing an enyo.Store and reimplementing enyo.Store.find? Maybe the enyo.Store.find should use any "localMerge" strategy as default instead of hardcoded:
    r  = (o.euid && rr.euid[o.euid]) || (a && a[pk] && rr.pk[p.kindName][a[pk]]);
// if we already found the record then we know that it was one of the cases where searching
// locally first worked so we return this value directly to the original success method
if (r) { return o.success(o, r); }
Sign In or Register to comment.