mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-01-22 16:49:22 -05:00
Merge pull request #160 from BakerNet/bugfix/reconnect-after-cleanup
bugfix: error when cleanup happens after reconnect attempt is on timeout
This commit is contained in:
commit
55f5ff9557
1 changed files with 7 additions and 0 deletions
|
@ -302,7 +302,11 @@ where
|
||||||
{
|
{
|
||||||
let reconnect_ref: StoredValue<Option<Rc<dyn Fn()>>> = store_value(None);
|
let reconnect_ref: StoredValue<Option<Rc<dyn Fn()>>> = store_value(None);
|
||||||
reconnect_ref.set_value({
|
reconnect_ref.set_value({
|
||||||
|
let unmounted = Rc::clone(&unmounted);
|
||||||
|
|
||||||
Some(Rc::new(move || {
|
Some(Rc::new(move || {
|
||||||
|
let unmounted = Rc::clone(&unmounted);
|
||||||
|
|
||||||
if !manually_closed_ref.get_value()
|
if !manually_closed_ref.get_value()
|
||||||
&& !reconnect_limit.is_exceeded_by(reconnect_times_ref.get_value())
|
&& !reconnect_limit.is_exceeded_by(reconnect_times_ref.get_value())
|
||||||
&& ws_ref
|
&& ws_ref
|
||||||
|
@ -312,6 +316,9 @@ where
|
||||||
reconnect_timer_ref.set_value(
|
reconnect_timer_ref.set_value(
|
||||||
set_timeout_with_handle(
|
set_timeout_with_handle(
|
||||||
move || {
|
move || {
|
||||||
|
if unmounted.get() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if let Some(connect) = connect_ref.get_value() {
|
if let Some(connect) = connect_ref.get_value() {
|
||||||
connect();
|
connect();
|
||||||
reconnect_times_ref.update_value(|current| *current += 1);
|
reconnect_times_ref.update_value(|current| *current += 1);
|
||||||
|
|
Loading…
Add table
Reference in a new issue