Closed valentinzberea closed 11 years ago
Ouch :(
There should be no duplicates in the API. Why do we have such a thing?
Let's say you are paginating through the results from Facebook API. You cannot control the results.
A workaround would be to define a postFetch
hook and in there trigger a no_data
event if nothing changed:
postFetch: (response) ->
if @previous_length? and @previous_length is @length
@trigger_no_data()
else
super(response)
@previous_length = @length
We are triggering an
invalidate
each time before fetch.https://github.com/uberVU/mozaic/blob/master/core/datasource/channel/read.coffee#L126-L131
And this is good because we can tell when a widget enter the
loading
state:But what happens when you try to add new items to a channel (paging scenario)? Before the fetch an
invalidate
is triggered followed by severaladd
events (each one for the new items added to collection).But when you receive only duplicates the
add
event is not triggered anymore and the state remains inloading
indefinitely.