pub trait MakeRx {
type Rx: MakeUnrx;
const HSR_IGNORE: bool = false;
// Required method
fn make_rx(self) -> Self::Rx;
}
Expand description
A trait for struct
s that can be made reactive. Typically, this will be
derived with the #[make_rx]
macro, though it can be implemented manually
if you have more niche requirements.
Required Associated Types§
Provided Associated Constants§
sourceconst HSR_IGNORE: bool = false
const HSR_IGNORE: bool = false
This should be set to true
to have this type be ignored by the hot
state reloading system, which can be useful when working with state
that you will regularly update in development.
For example, take a documentation website that converts Markdown to HTML
in its state generation process, storing that in reactive state. If you,
in development, then wanted to change some of the documentation and see
the result immediately, HSR would override the new state with the
old, preserving your ‘position’ in the development cycle. Only a
manual reload of the page would prevent this from continuing
forever. Setting this associated constant to true
will tell the
HSR system to ignore this type from HSR thawing, meaning
the new state will always be used. Note that, depending on the structure
of your application, this can sometimes cause state inconsistencies
(e.g. if one state object expects another one to be in a certain
state, but then one of them is ignored by HSR and resets).
This is a development-only setting, and does not exist in production. If
the hsr
feature flag is disabled, this will have no effect.
Typically, you would set this using the #[rx(hsr_ignore)]
derive
helper macro with #[derive(ReactiveState, ..)]
. Note that you only
need to set this to true
for the top-level state type for a page,
not for any nested components.