vue-rx
vue-rx copied to clipboard
Typescript types are incompletes
Hello,
We are using vue-rx with typescript and we encountered some issues:
- In
subscriptions
we can access to the properties defined indata
but the current vue-rx types say that we can't.
Note: It works if you use: subscriptions?: Observables | (() => Observables)
instead of subscriptions?: Observables | ((this: V) => Observables)
. But i didn't make a pull request because i am not sure that we can access to the props when subscriptions
is called.
-
this
is not extended with the data set by the subscriptions. So we can not access to the current values in the methods etc.
I have a same issue
Is there a solution?
I have same issue
I’m not familiar with ts type definitions, pull requests are welcomed. Or @keego give a check?
So I made a decorator binding lib.
https://github.com/MinuKang/vue-rx-decorators
I'm also noticing that things like props and methods aren't inferred for the component. Would adding the full set of generics fix this? This is what I mean:
declare module "vue/types/options" {
interface ComponentOptions<
V extends Vue,
Data = DefaultData<V>,
Methods = DefaultMethods<V>,
Computed = DefaultComputed,
PropsDef = PropsDefinition<DefaultProps>,
Props = DefaultProps
> {
subscriptions?: Observables | ((this: V) => Observables);
domStreams?: string[]
observableMethods?: string[] | Record<string, string>
}
}
I would like to use $fromDOMEvent('input', 'keyup')
inside my class component to have access to properties and methods. Is this possible? Something like this:
export default class MyComponent extends Vue {
....
private name;
private handleNameInput(observable: Observable<any>):Observable<any> {
return observable.pipe(
......
);
}
public created() {
this.handleNameInput($fromDOMEvent('input', 'keyup')).subscribe(
result => this.name = result
)
}
....
}