Skip to content

andrei512/SmartNotifications

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SmartNotifications

C wrapper for NSNotifications

Usage

Posting a notification:

post(@"NotificationName");
//or post with object 
posto(@"NotificationName", object);

Observing notifications:

//all the times @"NotificationName" is posted
when(@"NotificationName", ^{
  // do stuff here
  // the posted object is the tab00 variable
});
// just once
once(@"NotificationName", ^{
  // do stuff here
});
// k times
just(k, @"NotificationName", ^{
  // do stuff here
});

Invalidating a block:

//use the stop to invalidate the current scope and all subscopes
when(@"NotificationName", ^{
  // do stuff here
  stop    
  // this will not be executed  
});

Multiple events:

  when(@"a & b", ^{
      NSLog(@"when a & b");
  });
    
  once(@"a | b", ^{
      NSLog(@"once a | b");
  });
    
    
  when(@"a", ^{
      NSLog(@"when a");
  });
    
  post(@"a"); // will trigger @"a | b" and @"a"
  post(@"a"); // will trigger @"a"
  
  once(@"b", ^{
      NSLog(@"once b");
  });
  
  post(@"b"); // will trigger @"a & b" and @"b"
  post(@"b"); // nothing happens   

About

c wrapper for NSNotifications

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages