lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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