# bind_command_to_event

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactiveui/binding/command_binding/function-bind_command_to_event/

**function** · [`ferroui-reactiveui`](/docs/0.5.0/api/ferroui-reactiveui/) · v0.5.0

```rust
fn bind_command_to_event(command: std::rc::Rc<dyn ICommand>, command_parameter: &std::rc::Rc<dyn IObservable<crate::binding::interfaces::CommandParameter>>, subscribe: impl FnOnce(std::rc::Rc<dyn Fn() -> ()>) -> std::rc::Rc<dyn IDisposable>) -> std::rc::Rc<dyn IDisposable>
```

Executes `command` with the latest value of `command_parameter` whenever the event that
`subscribe` adds a handler to is raised, if the command can execute with it; disposing the
result removes the handler and ends the subscription of the parameter.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/command_binding/creates_command_binding_via_event.rs#L42)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
