New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InfinityModels managed by service + closure actions #271
Conversation
61f91a7
to
6c47ef6
Compare
e64f6a1
to
f197faa
Compare
a3fbe57
to
f000062
Compare
f000062
to
d6e9e2a
Compare
Lastly, by default, ember-infinity expects the server response to contain something about how many total pages it can expect to fetch. `ember-infinity` defaults to looking for something like `meta: { total_pages: 20 }` in your response. See [Advanced Usage](#AdvancedUsage). | ||
|
||
|
||
### Closure Actions<a name="ClosureActions"></a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
README details
this.sendAction('loadPreviousAction', infinityModelContent, -1); | ||
if (typeof(get(this, 'infinityLoad')) === 'function') { | ||
// closure action | ||
return get(this, 'infinityLoad')(infinityModelContent, -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new api for infinity-loader
} else { | ||
return true; | ||
} | ||
} | ||
}, | ||
|
||
/** | ||
@private |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move all logic to service
@@ -33,6 +33,7 @@ | |||
"ember-cli-htmlbars": "^2.0.1", | |||
"ember-cli-htmlbars-inline-precompile": "^1.0.0", | |||
"ember-cli-inject-live-reload": "^1.4.1", | |||
"ember-cli-mirage": "^0.4.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add mirage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't replaced all instances, but plan on fixing these over time.
@@ -0,0 +1,143 @@ | |||
import { module, test } from 'qunit'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace test (offset-trigger
) with general acceptance test
{{infinity-loader | ||
infinityModel=model | ||
infinityLoad=(action loadMorePosts) | ||
infinityLoadPrevious=(action loadMorePostsPrevious) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
examples using closure actions
infinityModel.replace(0, len, []); | ||
return infinityModel; | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace, flush, pushObjects, unshiftObjects. Not sure about having the same API as Ember though for pushObjects/unshiftObjects. Thoughts?
}; | ||
|
||
let convertToArray = (queryObject) => { | ||
if (queryObject.toArray) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also add if not an array, but an object, then make an array
InfinityModels managed by a service to provide an API to update, filter, set the list of infinityModels. Moreover, instead of bubbling actions to the route, this opens up the possibility for closure actions.
replace
,flush
,pushObjects
, andunshiftObjects
methodsinfinity-loader
component to accept a closure actionOne of the big benefits of closure actions is the ability to return a value or curry values; and although we don't necessarily need those in this example, I can see it useful for others.
Ref #272 #270
Will open up possibilities for #275