From f4864322baf3764cd7c7c9372d0c094b7b354887 Mon Sep 17 00:00:00 2001 From: Chris Brown <1731074+ccbrown@users.noreply.github.com> Date: Sun, 22 Dec 2024 21:13:53 -0500 Subject: [PATCH] docs: add notes to State::try_ methods --- packages/iocraft/src/hooks/use_state.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/iocraft/src/hooks/use_state.rs b/packages/iocraft/src/hooks/use_state.rs index 7aac458..40f1f4d 100644 --- a/packages/iocraft/src/hooks/use_state.rs +++ b/packages/iocraft/src/hooks/use_state.rs @@ -198,6 +198,9 @@ impl State { /// Returns a reference to the state's value, if its owner has not been dropped. /// + /// Most applications should not need to use this method. If you only read the state's value + /// from your component and its hooks, you should use [`read`](State::read) instead. + /// ///
It is possible to create a deadlock using this method. If you have /// multiple copies of the same state, writes to one will be blocked for as long as any /// reference returned by this method exists.
@@ -230,6 +233,9 @@ impl State { /// Returns a mutable reference to the state's value, if its owner has not been dropped. /// + /// Most applications should not need to use this method. If you only write the state's value + /// from your component and its hooks, you should use [`write`](State::write) instead. + /// ///
It is possible to create a deadlock using this method. If you have /// multiple copies of the same state, operations on one will be blocked for as long as any /// reference returned by this method exists.