Home

Awesome

Me

A super slim and in-place solution to the nested asynchronous computations problem

The mindset of software developers is changing, async programming represents 70% of the code in a cloud-based app and nested closures/blocks are a bad idea most of the time in terms of maintainability, readability and control (confusion about multiple vars with the same name in the same scope).

In order to deal with it, we wrote Me, a super slim piece of software (less than 200 lines) that acts like a magic by chaining your code instead of nesting it.

Example

Old method

MyAPI.login {
	//Do your stuff and then request posts...
	MyAPI.posts {
		//Do your stuff and then request comments...
		MyAPI.comments {
			//Do your stuff and then request likes...
			MyAPI.likes {
				//We are done here
			}
		}
	}
}

Me method

Me.start { (me) in
	MyAPI.login {
		//Do your stuff and then request posts...
		me.runNext()
	}
}.next { (caller, me) in
	MyAPI.posts {
		//Do your stuff and then request comments...
		me.runNext()
	}
}.next { (caller, me) in
	MyAPI.comments {
		//Do your stuff and then request likes...
		me.runNext()
	}
}.next { (caller, me) in
	MyAPI.likes {
		//We are done here
		me.end()
	}
}.run()

As you can see, the 'shifting' has been solved and the developer has the full control of the code's flow.

So, what the heck is the Me object??

The Me object is a proxy, an holder of the current block and the next in the chain.

Inside each block, you must add an instruction for the next block that should be executed, this is accomplished with runNext() or end()

N.B. If you don't call runNext(), the next block will not be executed

N.B. If you don't call end(), nothing will be released

Pros

Cons

Contacts

We would love to know if you are using Me in your app, send an email to pasquale.ambrosini@gmail.com