-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Custom component decorators #6643
Comments
I talked with @tbosch in length about this. We ended up at two conclusions. The 2nd use case ( @Component({
providers: [FirebaseList({
path: '/todos',
query: [['limitToFirst', 10]]
})],
template: `
<ul>
<li *ngFor="#todo of todos | async">
{{todo}}
</li>
</ul>
`
})
class MyComponent {
// FirebaseList would return a Provider that would depend on DEFAULT_FIREBASE
@InjectProp(FirebaseList) todos:Observable<Todo>;
} In today's Angular, I could go ahead and use @Component({
template: '<h1>Hi</h1>',
inputs:[],
providers: [
FirebaseList({
token: 'posts',
path: '/posts'
}),
FirebaseList({
token: 'todos',
path: '/todos'
}),
provide(DEFAULT_FIREBASE, {
useValue: 'ws://test.firebaseio.com'
})
]
})
class MyComponent {
constructor(@Inject('posts') public posts:Observable<any>, @Inject('todos') public todos:Observable<any>) {
}
} |
Would also be nice for things like defaulting to |
@jeffbcross @mhevery Is the issue relevant? I think this does not apply to angular |
obsolete |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Goals
Example Use Cases
@FirebaseList
property decorator@ViewEventObservable
property decorator@FirebaseList
Property DecoratorThis example would automatically create an Observable from a list of Todo objects from a Firebase.
I've prototyped a
@FirebaseList
decorator for the new AngularFire library (issue), but it has some downsides.@FirebaseList
DownsidesDEFAULT_FIREBASE
provider which gives the app's default Firebase urlObservable
and attaching it to the specified property of the component instance.I would like an API where I can tell Angular about my decorator, what dependencies it requires, and provide lifecycle callbacks so my library can do work at the appropriate time.
@ViewEventObservable
Property DecoratorWe'd like to provide some helpers to create observables from outputs and events of elements within a component's view, without requiring users to write imperative code and inject native elements into component code. If creating this decorator outside of Angular right now is even possible, it would require hacking into private Angular APIs or doing expensive DOM analysis to find the actual view for a component.
I've started thinking about a design for this, but wanted to open for discussion.
The text was updated successfully, but these errors were encountered: