[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: General purpose notification mechanism for Lua
- From: Petite Abeille <petite.abeille@...>
- Date: Mon, 4 Jan 2010 20:06:03 +0100
On Jan 4, 2010, at 2:01 PM, Tiago Katcipis wrote:
> We will start to build our lib today, i think it will not be something very
> useful to almost of you, but ill post it here.
FWIW, attached is a little notification mechanism akin in spirit to NSNotificationCenter [1].
Usage example:
local Notification = require( 'Notification' )
-- register some observers
Notification[ 'WillDoIt' ] = function( ... ) print( 'one', ... ) end
Notification[ 'DidIt' ] = function( ... ) print( 'two', ... ) end
Notification[ 'DidIt' ] = function( ... ) print( 'three', ... ) end
-- dispatch some notifications
Notification( 'WillDoIt', 1, 2, 3 )
Notification( 'DidIt', 1, 2, 3 )
> one WillDoIt 1 2 3
> two DidIt 1 2 3
> three DidIt 1 2 3
[1] http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSNotificationCenter_Class/
Attachment:
Notification.lua
Description: Binary data