Skip to content
/ libeem Public

A set of C macros used to transform any struct into an event emitter!

Notifications You must be signed in to change notification settings

pfrankw/libeem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libeem

A set of C macros used to transform any struct into an event emitter!

Why

By programming in an event-driven way, you often need to use some callbacks and/or fire events in your application.
I created this project in order to make this process easier.

How to use it?

It is REALLY simple.

Just create a struct that contains an eem_t element with the eem name:

struct my_obj {
	eem_t eem;
	// Your data here.
};

struct my_obj mo;

And then init it with:

EEM_INIT(&mo);

To subscribe events:

EEM_ON(&mo, EVENT_ID, CALLBACK, ARG);
// or
EEM_ONCE(&mo, EVENT_ID, CALLBACK, ARG);

To fire an event:

EEM_EMIT(&mo, EVENT_ID, DATA);

The callback must look like this:

void callback(eem_ev_t *ev, void *arg)
{
	// Funny event handling code
}

Examples

Just see the file programs/example.c. It is self-explaining.

About

A set of C macros used to transform any struct into an event emitter!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published