Skip to content

Commit

Permalink
wasm32 support (#13)
Browse files Browse the repository at this point in the history
* Use !Send types for wasm32 support.

* update example

* remove relative dependency and format

---------

Co-authored-by: muji <[email protected]>
  • Loading branch information
jpopesculian and tmpfs authored Oct 4, 2023
1 parent 6d43085 commit 084ce78
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/event_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,33 @@ use crate::retry::{RetryPolicy, DEFAULT_RETRY};
use core::pin::Pin;
use eventsource_stream::Eventsource;
pub use eventsource_stream::{Event as MessageEvent, EventStreamError};
use futures_core::future::{BoxFuture, Future};
use futures_core::stream::{BoxStream, Stream};
#[cfg(not(target_arch = "wasm32"))]
use futures_core::future::BoxFuture;
use futures_core::future::Future;
#[cfg(target_arch = "wasm32")]
use futures_core::future::LocalBoxFuture;
#[cfg(not(target_arch = "wasm32"))]
use futures_core::stream::BoxStream;
#[cfg(target_arch = "wasm32")]
use futures_core::stream::LocalBoxStream;
use futures_core::stream::Stream;
use futures_core::task::{Context, Poll};
use futures_timer::Delay;
use pin_project_lite::pin_project;
use reqwest::header::{HeaderName, HeaderValue};
use reqwest::{Error as ReqwestError, IntoUrl, RequestBuilder, Response, StatusCode};
use std::time::Duration;

#[cfg(not(target_arch = "wasm32"))]
type ResponseFuture = BoxFuture<'static, Result<Response, ReqwestError>>;
#[cfg(target_arch = "wasm32")]
type ResponseFuture = LocalBoxFuture<'static, Result<Response, ReqwestError>>;

#[cfg(not(target_arch = "wasm32"))]
type EventStream = BoxStream<'static, Result<MessageEvent, EventStreamError<ReqwestError>>>;
#[cfg(target_arch = "wasm32")]
type EventStream = LocalBoxStream<'static, Result<MessageEvent, EventStreamError<ReqwestError>>>;

type BoxedRetry = Box<dyn RetryPolicy + Send + Unpin + 'static>;

/// The ready state of an [`EventSource`]
Expand Down

0 comments on commit 084ce78

Please sign in to comment.