Skip to content

Commit 372f53e

Browse files
authored
feat: Dioxus 0.7 support (#44)
* feat: Dioxus 0.7 support * update dioxus dev dep * use stable 0.7 release
1 parent 8c6b951 commit 372f53e

File tree

4 files changed

+24
-30
lines changed

4 files changed

+24
-30
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "dioxus-query"
33
description = "Fully-typed, async, reusable cached state management for Dioxus 🧬"
4-
version = "0.8.1"
4+
version = "0.9.0"
55
edition = "2021"
66
license = "MIT"
77
authors = ["Marc Espín <[email protected]>"]
@@ -12,9 +12,9 @@ keywords = ["dioxus", "async", "state", "synchronization"]
1212
categories = ["gui", "asynchronous"]
1313

1414
[dependencies]
15-
dioxus-lib = { version = "0.6", default-features = false, features = ["macro", "hooks", "signals"] }
15+
dioxus = { version = "0.7.0", default-features = false, features = ["macro", "hooks", "signals"] }
16+
dioxus-core = { version = "0.7.0", default-features = false }
1617
futures-util = "0.3.28"
17-
warnings = "0.2.1"
1818
tokio = { version = "^1", features = ["sync", "time"] }
1919

2020
[target.'cfg(target_arch = "wasm32")'.dependencies]
@@ -23,5 +23,5 @@ web-time = "1.1.0"
2323
tokio = { version = "^1", features = ["sync"] }
2424

2525
[dev-dependencies]
26-
dioxus = { version = "0.6", features = ["desktop"] }
26+
dioxus = { version = "0.7.0", features = ["desktop"] }
2727
tokio = { version = "^1", features = ["time"] }

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ See the [Docs](https://docs.rs/dioxus-query/latest/dioxus_query/) or join the [D
88

99
## Support
1010

11-
- **Dioxus v0.6** 🧬
12-
- All renderers ([web](https://dioxuslabs.com/learn/0.4/getting_started/wasm), [desktop](https://dioxuslabs.com/learn/0.4/getting_started/desktop), [freya](https://github.com/marc2332/freya), etc)
13-
- Both WASM and native targets
11+
- **Dioxus v0.7** 🧬
12+
- Web, Desktop, and Blitz support
1413

1514
## Features
1615
- [x] **Renderer-agnostic**

src/mutation.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
use core::fmt;
2+
use dioxus::prelude::*;
3+
use dioxus::{
4+
hooks::{use_memo, use_reactive},
5+
signals::CopyValue,
6+
};
7+
use dioxus_core::{provide_root_context, spawn_forever, use_drop, ReactiveContext, Task};
28
use std::{
39
cell::{Ref, RefCell},
410
collections::{HashMap, HashSet},
@@ -9,13 +15,6 @@ use std::{
915
sync::{Arc, Mutex},
1016
time::Duration,
1117
};
12-
13-
use dioxus_lib::prelude::*;
14-
use dioxus_lib::signals::{Readable, Writable};
15-
use dioxus_lib::{
16-
hooks::{use_memo, use_reactive},
17-
signals::CopyValue,
18-
};
1918
#[cfg(not(target_family = "wasm"))]
2019
use tokio::time;
2120
#[cfg(not(target_family = "wasm"))]
@@ -187,14 +186,14 @@ impl<Q: MutationCapability> MutationsStorage<Q> {
187186

188187
// Spawn clean up task if there no more reactive contexts
189188
if mutation_data.reactive_contexts.lock().unwrap().is_empty() {
190-
*mutation_data.clean_task.borrow_mut() = spawn_forever(async move {
189+
*mutation_data.clean_task.borrow_mut() = Some(spawn_forever(async move {
191190
// Wait as long as the stale time is configured
192191
time::sleep(mutation.clean_time).await;
193192

194193
// Finally clear the mutation
195194
let mut storage = storage_clone.write();
196195
storage.remove(&mutation);
197-
});
196+
}));
198197
}
199198
}
200199

src/query.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ use std::{
1010
time::Duration,
1111
};
1212

13-
use ::warnings::Warning;
14-
use dioxus_lib::prelude::Task;
15-
use dioxus_lib::prelude::*;
16-
use dioxus_lib::signals::{Readable, Writable};
17-
use dioxus_lib::{
13+
use dioxus::prelude::*;
14+
use dioxus::{
1815
hooks::{use_memo, use_reactive},
1916
signals::CopyValue,
2017
};
18+
use dioxus_core::{
19+
provide_root_context, spawn_forever, use_drop, ReactiveContext, SuspendedFuture, Task,
20+
};
2121
use futures_util::stream::{FuturesUnordered, StreamExt};
2222
use tokio::sync::Notify;
2323
#[cfg(not(target_family = "wasm"))]
@@ -235,8 +235,7 @@ impl<Q: QueryCapability> QueriesStorage<Q> {
235235
// Run the query
236236
QueriesStorage::<Q>::run_queries(&[(&query_clone, &query_data_clone)]).await;
237237
}
238-
})
239-
.expect("Failed to spawn interval task.");
238+
});
240239
*interval_task = Some((interval, task));
241240
}
242241

@@ -256,14 +255,14 @@ impl<Q: QueryCapability> QueriesStorage<Q> {
256255

257256
// Spawn clean up task if there no more reactive contexts
258257
if query_data.reactive_contexts.lock().unwrap().is_empty() {
259-
*query_data.clean_task.borrow_mut() = spawn_forever(async move {
258+
*query_data.clean_task.borrow_mut() = Some(spawn_forever(async move {
260259
// Wait as long as the stale time is configured
261260
time::sleep(query.clean_time).await;
262261

263262
// Finally clear the query
264263
let mut storage = storage_clone.write();
265264
storage.remove(&query);
266-
});
265+
}));
267266
}
268267
}
269268

@@ -318,14 +317,14 @@ impl<Q: QueryCapability> QueriesStorage<Q> {
318317

319318
// Spawn clean up task if there no more reactive contexts
320319
if query_data.reactive_contexts.lock().unwrap().is_empty() {
321-
*query_data.clean_task.borrow_mut() = spawn_forever(async move {
320+
*query_data.clean_task.borrow_mut() = Some(spawn_forever(async move {
322321
// Wait as long as the stale time is configured
323322
time::sleep(query.clean_time).await;
324323

325324
// Finally clear the query
326325
let mut storage = storage.storage.write();
327326
storage.remove(&query);
328-
});
327+
}));
329328
}
330329

331330
QueryReader {
@@ -610,9 +609,6 @@ impl<Q: QueryCapability> UseQuery<Q> {
610609
Q::Ok: Clone,
611610
Q::Err: Clone,
612611
{
613-
let _allow_write_in_component_body =
614-
::warnings::Allow::new(warnings::signal_write_in_component_body::ID);
615-
616612
let storage = consume_context::<QueriesStorage<Q>>();
617613
let mut storage = storage.storage.write_unchecked();
618614
let query_data = storage.get_mut(&self.query.peek()).unwrap();

0 commit comments

Comments
 (0)