dioxus-maplibre 0.0.7

MapLibre GL JS wrapper for Dioxus 0.7
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Shared map-handle context and hook helpers.

use dioxus::prelude::{Signal, try_use_context};

use crate::handle::MapHandle;

pub(crate) type MapHandleSignal = Signal<Option<MapHandle>>;

pub(crate) fn try_use_map_handle_signal() -> Option<MapHandleSignal> {
    try_use_context::<MapHandleSignal>()
}

/// Access the nearest `Map` handle from context.
///
/// Returns `None` when called outside a `Map` subtree or before map initialization.
pub fn use_map_handle() -> Option<MapHandle> {
    try_use_map_handle_signal().and_then(|signal| signal())
}