basic implementation of Observer Pattern in C.
gem install ceedling
ceedling test:observer
To add Observable property to certain object,
- Place
Observable
type as the first field of your sturct. - Call
Observable_init
to activate - If some module wants to be notified, register appropriate handler with
Observable_attach
- Now that will make anything can be updated when
Observable_notify
called.
See test/test_observable.c
for example.