← Back

ofxLambdaEvent

github.com/2bbb/ofxLambdaEvent · @2bbb
OF 0.9 Archived Utilities

we don't want to do static_cast explicitly.

3 1 Last commit 10y ago Created 10y ago

README

ofxLambdaEvent



we don't want to do static_cast explicitly.

Dependencies



no dependency!

What is this?



from:

	ofAddListener(ofEvents().update, static_cast<void()(ofEventArgs &)>([](ofEventArgs &) {
		ofLogNotice() << "update!";
	}));


to:

	ofAddLambdaListener(ofEvents().update, [](ofEventArgs &) {
		ofLogNotice() << "update!";
	});


Notice



if use this, then we can't do ofRemoveListener.

therefore, i can't provide ofRemoveLambdaListener.

ofcourse, we can do as below:

	std::function<void(ofEventArgs &)> callback;
	
	...
	
	callback = [](ofEventArgs &) {
		ofLogNotice() << "update!";
	};
	
	ofAddLambdaListener(ofEvents().update, callback);
	
	...
	
	ofRemoveListener(ofEvents().update, callback);


but, then we can use formal ofAddListener.

i have a idea that is dirty. but i think, we don't need function removes listener.

Update history



2016/04/14 ver 0.0.1 release



License



MIT License.

Author



ISHII 2bit [bufferRenaiss co., ltd.] ishii[at]buffer-renaiss.com

At the last



Please create a new issue if there is a problem. And please throw a pull request if you have a cool idea!!

Get this addon

HTTPS
SSH