Skip to content

Implementation of the observer software design pattern / an event emitter for the rust programming language.

Notifications You must be signed in to change notification settings

49nord/observer-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

observer-rs

Build Status Crates.io version

Implementation of the observer software design pattern (also known as event emitter) for rust.

See the documentation for details.

struct Model {
    counter: usize,
}

impl Model {
        fn increment(&mut self) {
            self.counter += 1;
        }
}

let model = Model { counter: 42 };

// create a subject that can be observed
let mut subject = Subject::new(model);
// add a function that is informed about changes
subject.register(|v: &mut Model| println!("new counter value: {}", v.counter));

subject.get_mut_notify().increment();

About

Implementation of the observer software design pattern / an event emitter for the rust programming language.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages