Skip to content

Commit

Permalink
fix: added load_error event
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelOsborne committed Feb 2, 2024
1 parent a59223b commit d6b9b72
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions dotlottie-ffi/src/dotlottie_player.udl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace dotlottie_player {
[Trait, WithForeign]
interface Observer {
void on_load();
void on_load_error();
void on_play();
void on_pause();
void on_stop();
Expand Down
1 change: 1 addition & 0 deletions dotlottie-ffi/src/dotlottie_player_cpp.udl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace dotlottie_player {
[Trait]
interface Observer {
void on_load();
void on_load_error();
void on_play();
void on_pause();
void on_stop();
Expand Down
25 changes: 25 additions & 0 deletions dotlottie-rs/src/dotlottie_player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::lottie_renderer::{LottieRenderer, LottieRendererError};

pub trait Observer: Send + Sync {
fn on_load(&self);
fn on_load_error(&self);
fn on_play(&self);
fn on_pause(&self);
fn on_stop(&self);
Expand Down Expand Up @@ -629,6 +630,12 @@ impl DotLottiePlayer {
self.observers.read().unwrap().iter().for_each(|observer| {
observer.on_load();
});
} else {
self.observers.read().unwrap().iter().for_each(|observer| {
observer.on_load_error();
});

return false;
}

is_ok
Expand All @@ -644,6 +651,12 @@ impl DotLottiePlayer {
self.observers.read().unwrap().iter().for_each(|observer| {
observer.on_load();
});
} else {
self.observers.read().unwrap().iter().for_each(|observer| {
observer.on_load_error();
});

return false;
}

is_ok
Expand All @@ -659,6 +672,12 @@ impl DotLottiePlayer {
self.observers.read().unwrap().iter().for_each(|observer| {
observer.on_load();
});
} else {
self.observers.read().unwrap().iter().for_each(|observer| {
observer.on_load_error();
});

return false;
}

is_ok
Expand All @@ -674,6 +693,12 @@ impl DotLottiePlayer {
self.observers.read().unwrap().iter().for_each(|observer| {
observer.on_load();
});
} else {
self.observers.read().unwrap().iter().for_each(|observer| {
observer.on_load_error();
});

return false;
}

is_ok
Expand Down

0 comments on commit d6b9b72

Please sign in to comment.