Wait for back end

2 views
Skip to first unread message

Кирилл Ширинкин

unread,
Sep 15, 2011, 4:57:45 PM9/15/11
to lebow...@googlegroups.com
Does lebowski have some nice way of waiting for back end and data source response? Except checking for some view is defined.

Problem is that i have form for new record, then user submits this form and gets list of records, but this new record appears after, let say. 2-3 seconds after submit (datasource needs time to fetch remote query and get new info from server). So my test for listView to have this new item_view fails, because lebowski checks for this item right after it clicked the Submit button.

Also, sometimes requests to server takes too long time (like 20-30 secs). I am not sure if it's lebowski bug, though i don't have this long requests when testing app manually.

MikeC

unread,
Sep 15, 2011, 6:06:42 PM9/15/11
to lebowskifw
With Lebowski, you are not restricted to just accessing views within
your SproutCore app. You can access any SproutCore object:
controllers, model objects, data stores, etc. Therefore, when
accessing records from a remote source, you can, for instance, use a
record or record array's status property to check if data has been
returned from the server. If the status is SC.Record.BUSY then you
continue to wait. Example:

App.wait_until do |app|
return app['path.to.record.status'] == app['$SC.Record.READY']
end

Above we use wait_until to keep checking a record object's status
property and determine if it is equal to the READY constant and if so
continue. Note the use of $SC which means to use SC and the root
object instead of the app's root object, such as 'MyApp'.

If you're not making use of record objects returned from the data
store to check their status, you can instead setup properties on a
controller that indicates the loading of data. When a callback is
fired by the datastore that causes the controller's property to
change, then that is confirmation that data came back. Example:

App.wait_until do |app|
return app['someController.isFooDataLoaded']
end

So long as isFooDataLoaded is false you will remain in the wait_until
block until a timeout occurs.

Given the two options, the more preferred approach is to leverage a
record's status property.

Regarding the long response times you're getting using Lebowski,
unfortunately I'm not sure why that would be happening.

-Mike
Reply all
Reply to author
Forward
0 new messages