diff --git a/examples-wasm/examples/subscriptions.rs b/examples-wasm/examples/subscriptions.rs index f4c4882..4548f96 100644 --- a/examples-wasm/examples/subscriptions.rs +++ b/examples-wasm/examples/subscriptions.rs @@ -57,7 +57,7 @@ async fn main() { let connection = Connection::new(ws_conn).await; - let (mut client, actor) = Client::build(connection).await.unwrap(); + let (client, actor) = Client::build(connection).await.unwrap(); wasm_bindgen_futures::spawn_local(actor.into_future()); let mut stream = client.subscribe(build_query()).await.unwrap(); diff --git a/examples/examples/cynic-mulitiple-subscriptions.rs b/examples/examples/cynic-mulitiple-subscriptions.rs index 7f288d5..da06220 100644 --- a/examples/examples/cynic-mulitiple-subscriptions.rs +++ b/examples/examples/cynic-mulitiple-subscriptions.rs @@ -55,7 +55,7 @@ async fn main() { println!("Connected"); - let (mut client, actor) = Client::build(connection).await.unwrap(); + let (client, actor) = Client::build(connection).await.unwrap(); async_std::task::spawn(actor.into_future()); // In reality you'd probably want to different subscriptions, but for the sake of this example diff --git a/examples/examples/tokio.rs b/examples/examples/tokio.rs index ae408fb..e6e64b8 100644 --- a/examples/examples/tokio.rs +++ b/examples/examples/tokio.rs @@ -54,7 +54,7 @@ async fn main() { println!("Connected"); - let (mut client, actor) = Client::build(connection).await.unwrap(); + let (client, actor) = Client::build(connection).await.unwrap(); tokio::spawn(actor.into_future()); let mut stream = client.subscribe(build_query()).await.unwrap(); diff --git a/src/next/builder.rs b/src/next/builder.rs index 3a70ecb..3486121 100644 --- a/src/next/builder.rs +++ b/src/next/builder.rs @@ -105,7 +105,7 @@ impl ClientBuilder { where Operation: GraphqlOperation + Unpin + Send + 'static, { - let (mut client, actor) = self.await?; + let (client, actor) = self.await?; let mut actor_future = actor.into_future().fuse(); diff --git a/src/next/mod.rs b/src/next/mod.rs index c200a2f..4339874 100644 --- a/src/next/mod.rs +++ b/src/next/mod.rs @@ -47,6 +47,7 @@ pub use self::{ /// } /// # Ok(()) /// # } +#[derive(Clone)] pub struct Client { actor: mpsc::Sender, subscription_buffer_size: usize, @@ -69,7 +70,7 @@ impl Client { /// /// Returns a `Stream` of responses. pub async fn subscribe<'a, Operation>( - &mut self, + &self, op: Operation, ) -> Result, Error> where @@ -87,7 +88,8 @@ impl Client { let request = serde_json::to_string(&message) .map_err(|error| Error::Serializing(error.to_string()))?; - self.actor + let mut actor = self.actor.clone(); + actor .send(ConnectionCommand::Subscribe { request, sender, @@ -102,7 +104,7 @@ impl Client { op.decode(response) .map_err(|err| Error::Decode(err.to_string())) })), - actor: self.actor.clone(), + actor, }) } diff --git a/tests/cynic-tests.rs b/tests/cynic-tests.rs index be581e4..dd6a94f 100644 --- a/tests/cynic-tests.rs +++ b/tests/cynic-tests.rs @@ -72,7 +72,7 @@ async fn main_test() { println!("Connected"); - let (mut client, actor) = graphql_ws_client::Client::build(connection).await.unwrap(); + let (client, actor) = graphql_ws_client::Client::build(connection).await.unwrap(); tokio::spawn(actor.into_future()); diff --git a/tests/graphql-client-tests.rs b/tests/graphql-client-tests.rs index 5de44d2..854d336 100644 --- a/tests/graphql-client-tests.rs +++ b/tests/graphql-client-tests.rs @@ -37,7 +37,7 @@ async fn main_test() { println!("Connected"); - let (mut client, actor) = graphql_ws_client::Client::build(connection).await.unwrap(); + let (client, actor) = graphql_ws_client::Client::build(connection).await.unwrap(); tokio::spawn(actor.into_future());