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

Observable.fromEventConversion have wrong generic signature #168

Open
shirok1 opened this issue Aug 14, 2022 · 0 comments
Open

Observable.fromEventConversion have wrong generic signature #168

shirok1 opened this issue Aug 14, 2022 · 0 comments

Comments

@shirok1
Copy link

shirok1 commented Aug 14, 2022

I'm trying to convert GlobalSystemMediaTransportControlsSession.MediaPropertiesChanged to IObservable. However, it delegates a TypedEventHandler, not EventArgs, so a conversion is needed and ...

let conversion (handler: EventHandler<_>) : Windows.Foundation.TypedEventHandler<_, _> =
    Windows.Foundation.TypedEventHandler(fun s e -> handler.Invoke(s, e))

Observable.fromEventConversionOn
    Scheduler.Scheduler.EventLoop
    conversion
    session.add_MediaPropertiesChanged
    session.remove_MediaPropertiesChanged

// Following doesn't compile
Observable.fromEventConversion
    conversion
    session.add_MediaPropertiesChanged
    session.remove_MediaPropertiesChanged

In decompiler:

image

I also wonder if there is better solution (for TypedEventHandler), Observable.fromEventGeneric doesn't work.

Type constraint mismatch. The type ''a -> unit' is not compatible with type 'Windows.Foundation.TypedEventHandler<GlobalSystemMediaTransportControlsSession,MediaPropertiesChangedEventArgs>'
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

1 participant