vuejs / vue-rx

👁️ RxJS integration for Vue.js.
MIT License
3.35k stars 190 forks source link

Typescript types are incompletes #88

Open AntoineEsteve opened 6 years ago

AntoineEsteve commented 6 years ago

Hello,

We are using vue-rx with typescript and we encountered some issues:

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.

Terry-bear commented 6 years ago

I have a same issue

olivewind commented 6 years ago

Is there a solution?

ananiy commented 6 years ago

I have same issue

regou commented 6 years ago

I’m not familiar with ts type definitions, pull requests are welcomed. Or @keego give a check?

minuukang commented 6 years ago

So I made a decorator binding lib.

https://github.com/MinuKang/vue-rx-decorators

alexsasharegan commented 5 years ago

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>
    }
}
raybog commented 5 years ago

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
    )
  } 
....
}