Skip to content

Commit

Permalink
Passing database instance to listen callback and remove Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
abdolence committed Feb 6, 2023
1 parent 7b4034c commit df2b6a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/listen-changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
.add_target(TEST_TARGET_ID_BY_DOC_IDS, &mut listener)?;

listener
.start(|event| async move {
.start(|event, _edb| async move {
match event {
FirestoreListenEvent::DocumentChange(ref doc_change) => {
println!("Doc changed: {doc_change:?}");
Expand Down
10 changes: 5 additions & 5 deletions src/db/listen_changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ where

pub async fn start<FN, F>(&mut self, cb: FN) -> FirestoreResult<()>
where
FN: Fn(FirestoreListenEvent) -> F + Send + Sync + 'static,
F: Future<Output = BoxedErrResult<()>> + Send + Sync + 'static,
FN: Fn(FirestoreListenEvent, D) -> F + Send + Sync + 'static,
F: Future<Output = BoxedErrResult<()>> + Send + 'static,
{
info!(
"Starting a Firestore listener for targets: {:?}...",
Expand Down Expand Up @@ -296,8 +296,8 @@ where
cb: FN,
) where
D: FirestoreListenSupport + Clone + Send + Sync,
FN: Fn(FirestoreListenEvent) -> F + Send + Sync,
F: Future<Output = BoxedErrResult<()>> + Send + Sync,
FN: Fn(FirestoreListenEvent, D) -> F + Send + Sync,
F: Future<Output = BoxedErrResult<()>> + Send,
{
while !shutdown_flag.load(Ordering::Relaxed) {
debug!("Start listening on targets {:?}... ", targets_state.len());
Expand Down Expand Up @@ -342,7 +342,7 @@ where

}
Some(response_type) => {
if let Err(err) = cb(response_type).await {
if let Err(err) = cb(response_type, db.clone()).await {
error!("Listener callback function error occurred {:?}.", err);
break;
}
Expand Down

0 comments on commit df2b6a4

Please sign in to comment.