Macro impl_section_custom

Source
macro_rules! impl_section_custom {
    ($name:ident, $json:ty, $patch_json:ty, $url:expr, $($element:ident),*) => { ... };
}
Expand description

UI macro: implements a REST API section using custom functionality.

This UI macro is used to implement the interaction between the UI and a section of the REST API using some custom functions. See impl_section for the equivalent without custom functions.

This macro includes the following:

  • impl_patch call to implement a method that sends a PATCH request.

  • impl_update_elements call to implement methods to update the UI elements.

  • impl_onchange call to implement onchange methods for each element that perform a PATCH request and update all the UI elements of this section using the result.

  • Implements a patch_name_update_elements of signature async fn patch_name_update_elements(&self, json: &$patch_json) -> Result<(), JsValue> that updates the api_state member of the UI with the json data, calls the update_name_all_elements method to update the contents of UI elements to match the server-side state, and calls the user-defined post_patch_name_update_elements with the json to perform any required user-defined functionality.

See impl_section for an example.