#![doc = include_str!("../README.md")]
mod engine;
#[cfg(feature = "navigation-binding")]
pub mod navigation;
#[cfg(feature = "isolated-channels")]
pub mod isolated_channels;
pub mod ffi;
pub mod runtime;
#[cfg(feature = "state-persistence")]
pub mod persistence;
pub use engine::InitContext;
pub use engine::{
CoreResult, OxideError, Reducer, ReducerEngine, SlicedState, StateChange, StateSnapshot,
};
pub use engine::Context;
pub type ReducerCtx<'a, Input, State, StateSlice = ()> =
engine::Context<'a, Input, State, StateSlice>;
pub fn init_engine_globals() -> CoreResult<()> {
#[cfg(feature = "navigation-binding")]
{
engine::init_navigation()?;
}
#[cfg(feature = "isolated-channels")]
{
isolated_channels::init_isolated_channels()?;
}
Ok(())
}
#[cfg(feature = "frb-spawn")]
pub fn init_from_frb(thread_pool_provider: fn() -> runtime::ThreadPool) -> CoreResult<()> {
let _ = runtime::init(thread_pool_provider);
init_engine_globals()?;
Ok(())
}
#[cfg(not(feature = "frb-spawn"))]
pub fn init_from_frb(_thread_pool_provider: fn() -> ()) -> CoreResult<()> {
runtime::ensure_initialized()?;
init_engine_globals()?;
Ok(())
}
#[cfg(feature = "navigation-binding")]
pub use engine::{
NavigationCtx, NavigationRuntime, init_navigation, navigation_runtime,
};
#[cfg(feature = "isolated-channels")]
pub use isolated_channels::{
CallbackRuntime, EventChannelRuntime, IncomingHandler, OxideCallbacking, OxideChannelError,
OxideChannelResult, OxideEventChannel, OxideEventDuplexChannel, ensure_isolated_channels_initialized,
init_isolated_channels, isolated_channels_initialized, isolated_channels_runtime,
OxideIsolatedChannelsRuntime,
};
pub use ffi::watch_receiver_to_stream;
pub use tokio;
#[cfg(any(feature = "state-persistence", feature = "navigation-binding"))]
pub use serde;
#[cfg(test)]
mod tests;