Skip to content
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

Inside a component? #180

Closed
rmcsharry opened this issue Sep 9, 2016 · 6 comments
Closed

Inside a component? #180

rmcsharry opened this issue Sep 9, 2016 · 6 comments

Comments

@rmcsharry
Copy link

I know this has been asked many times but nobody has ever posted code or a guide, so I am stumped.

How does anyone use this amazing add on inside their own component?

I have tried absolutely everything in the past 14 hours to get a simple 'bubble action' for infinityLoad to propagate up to the route where the model is defined and trigger the 2nd page.

Code is here.

@hhff
Copy link
Collaborator

hhff commented Sep 13, 2016

Hi @rmcsharry ! Sorry you're having trouble. Everything works just like in regular ember - you just need to pass the action up the tree.

Inside your component:

export default YourComponent.extend({
  infinityLoadAction: 'infinityLoad',
  actions: {
    infinityLoad(infinityModel) {
      this.sendAction('infinityLoadAction', infinityModel);
    }
  }
})

Let me know!

@hhff hhff mentioned this issue Sep 13, 2016
@rmcsharry
Copy link
Author

I managed to get the action to bubble up, but it never triggered the model to reload. Perhaps because I never passed 'infinityModel' as the second param in the sendAction call. I'll try again tomorrow now I've seen your response. Thanks, btw!

@hhff
Copy link
Collaborator

hhff commented Sep 14, 2016

Yup - that would be the reason! It needs that to handle nested
infinityRoutes

On Wed, 14 Sep 2016 at 15:03 Richard McSharry [email protected]
wrote:

I managed to get the action to bubble up, but it never triggered the model
to reload. Perhaps because I never passed 'infinityModel' as the second
param in the sendAction call. I'll try again tomorrow now I've seen your
response. Thanks, btw!


You are receiving this because you commented.

Reply to this email directly, view it on GitHub
#180 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACu4_ENqvUvkDwShpHnYtNedWTBNJlFcks5qqETqgaJpZM4J44rZ
.

@rmcsharry
Copy link
Author

@hhff Thanks for your help, it now works!

Why do you say in the other thread that you don't really recommend using it in a component?

You also said you can't think of a good use case. I have one 👍

I am hoping I can now extend my component to be a 'generic' listing component that can take different models and list out the data in a basic way, and infinity-load it.

Think of an old-fashioned table - you just tell it what data to display and it gets laid out in rows and columns. So a basic version of that, but just a simple list, which basically has 3 inputs: the data model, a sort order, a route-action to select an item. Maybe later I can add a search filter box.

This then allows you to build an app very quickly - just drop in the component for each 'index' route. It's a kind of 'wireframe' component I guess that later you will replace with something more polished. Or maybe I'll enhance it to accept a template to go with the data ;)

@hhff
Copy link
Collaborator

hhff commented Sep 16, 2016

Got it! Usually in that case I'd recommend having the list component be siblings to the infinity-loader. Different strokes for different folks, but I prefer my components being composable, rather then complex & nested.

@rmcsharry
Copy link
Author

Good point, I cannot disagree with composition as a strategy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants