Skip to content

Commit

Permalink
remove refcell
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy committed Oct 10, 2023
1 parent 45f81ab commit e2246ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions crates/torii/client/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub mod error;
pub mod storage;
pub mod subscription;

use std::cell::{OnceCell, RefCell};
use std::cell::OnceCell;
use std::sync::Arc;

use dojo_types::packing::unpack;
Expand All @@ -27,7 +27,7 @@ pub struct Client {
/// Metadata of the World that the client is connected to.
metadata: Arc<RwLock<WorldMetadata>>,
/// The grpc client.
inner: RefCell<torii_grpc::client::WorldClient>,
inner: torii_grpc::client::WorldClient,
/// Entity storage
storage: Arc<ModelStorage>,
/// Entities the client are subscribed to.
Expand Down Expand Up @@ -73,9 +73,8 @@ impl Client {

/// Initiate the entity subscriptions and returns a [SubscriptionService] which when await'ed
/// will execute the subscription service and starts the syncing process.
pub async fn start_subscription(&self) -> Result<SubscriptionService, Error> {
let sub_res_stream =
self.inner.borrow_mut().subscribe_entities(self.synced_entities()).await?;
pub async fn start_subscription(&mut self) -> Result<SubscriptionService, Error> {
let sub_res_stream = self.inner.subscribe_entities(self.synced_entities()).await?;

let (service, handle) = SubscriptionService::new(
Arc::clone(&self.storage),
Expand Down Expand Up @@ -152,9 +151,9 @@ impl ClientBuilder {
}

Ok(Client {
inner: grpc_client,
storage: client_storage,
metadata: shared_metadata,
inner: RefCell::new(grpc_client),
sub_client_handle: OnceCell::new(),
subscribed_entities: subbed_entities,
})
Expand Down
2 changes: 1 addition & 1 deletion crates/torii/client/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub async fn spawn_client(
JsValue::from_str(format!("failed to parse world address: {err}").as_str())
})?;

let client = torii_client::client::ClientBuilder::new()
let mut client = torii_client::client::ClientBuilder::new()
.set_entities_to_sync(entities)
.build(torii_url.into(), rpc_url.into(), world_address)
.await
Expand Down

0 comments on commit e2246ef

Please sign in to comment.