File tree Expand file tree Collapse file tree 7 files changed +11
-9
lines changed Expand file tree Collapse file tree 7 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ async fn main() {
57
57
58
58
let connection = Connection :: new ( ws_conn) . await ;
59
59
60
- let ( mut client, actor) = Client :: build ( connection) . await . unwrap ( ) ;
60
+ let ( client, actor) = Client :: build ( connection) . await . unwrap ( ) ;
61
61
wasm_bindgen_futures:: spawn_local ( actor. into_future ( ) ) ;
62
62
63
63
let mut stream = client. subscribe ( build_query ( ) ) . await . unwrap ( ) ;
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ async fn main() {
55
55
56
56
println ! ( "Connected" ) ;
57
57
58
- let ( mut client, actor) = Client :: build ( connection) . await . unwrap ( ) ;
58
+ let ( client, actor) = Client :: build ( connection) . await . unwrap ( ) ;
59
59
async_std:: task:: spawn ( actor. into_future ( ) ) ;
60
60
61
61
// In reality you'd probably want to different subscriptions, but for the sake of this example
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ async fn main() {
54
54
55
55
println ! ( "Connected" ) ;
56
56
57
- let ( mut client, actor) = Client :: build ( connection) . await . unwrap ( ) ;
57
+ let ( client, actor) = Client :: build ( connection) . await . unwrap ( ) ;
58
58
tokio:: spawn ( actor. into_future ( ) ) ;
59
59
60
60
let mut stream = client. subscribe ( build_query ( ) ) . await . unwrap ( ) ;
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ impl ClientBuilder {
105
105
where
106
106
Operation : GraphqlOperation + Unpin + Send + ' static ,
107
107
{
108
- let ( mut client, actor) = self . await ?;
108
+ let ( client, actor) = self . await ?;
109
109
110
110
let mut actor_future = actor. into_future ( ) . fuse ( ) ;
111
111
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ pub use self::{
47
47
/// }
48
48
/// # Ok(())
49
49
/// # }
50
+ #[ derive( Clone ) ]
50
51
pub struct Client {
51
52
actor : mpsc:: Sender < ConnectionCommand > ,
52
53
subscription_buffer_size : usize ,
@@ -69,7 +70,7 @@ impl Client {
69
70
///
70
71
/// Returns a `Stream` of responses.
71
72
pub async fn subscribe < ' a , Operation > (
72
- & mut self ,
73
+ & self ,
73
74
op : Operation ,
74
75
) -> Result < Subscription < Operation > , Error >
75
76
where
@@ -87,7 +88,8 @@ impl Client {
87
88
let request = serde_json:: to_string ( & message)
88
89
. map_err ( |error| Error :: Serializing ( error. to_string ( ) ) ) ?;
89
90
90
- self . actor
91
+ let mut actor = self . actor . clone ( ) ;
92
+ actor
91
93
. send ( ConnectionCommand :: Subscribe {
92
94
request,
93
95
sender,
@@ -102,7 +104,7 @@ impl Client {
102
104
op. decode ( response)
103
105
. map_err ( |err| Error :: Decode ( err. to_string ( ) ) )
104
106
} ) ) ,
105
- actor : self . actor . clone ( ) ,
107
+ actor,
106
108
} )
107
109
}
108
110
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ async fn main_test() {
72
72
73
73
println ! ( "Connected" ) ;
74
74
75
- let ( mut client, actor) = graphql_ws_client:: Client :: build ( connection) . await . unwrap ( ) ;
75
+ let ( client, actor) = graphql_ws_client:: Client :: build ( connection) . await . unwrap ( ) ;
76
76
77
77
tokio:: spawn ( actor. into_future ( ) ) ;
78
78
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ async fn main_test() {
37
37
38
38
println ! ( "Connected" ) ;
39
39
40
- let ( mut client, actor) = graphql_ws_client:: Client :: build ( connection) . await . unwrap ( ) ;
40
+ let ( client, actor) = graphql_ws_client:: Client :: build ( connection) . await . unwrap ( ) ;
41
41
42
42
tokio:: spawn ( actor. into_future ( ) ) ;
43
43
You can’t perform that action at this time.
0 commit comments