<commit_before>[![Build Status](https://travis-ci.org/tangye1234/Promise.png)](https://travis-ci.org/tangye1234/Promise)
A Promise for android
======================

A Promise library for android which follows Promise/A+ standard

[![Promise/A+](https://rawgithub.com/promises-aplus/promises-spec/master/logo.svg)](https://promisesaplus.com/ "Promise/A+")

Introduction
=============

Nearly, all android promise open-source projects offer us a tool, which has async-thread-execution being involved
into their component. I must say, it is good, since `AsyncTask` is just like that - executing tasks in
a pre-built task-executors, or let user provide one for `AsyncTask`. But I think, Promise should just focus on
async processing functions with callbacks, without making any extra thread or using executors to handle `runnable`
or `Callable` process.

The Promise lib here dose not do any thread-making stuff, or not depends on any executors. It just produce a
`Deferred` object, letting you decide when to `resolve` a deferred or `reject` a deferred. Then making `then` on
a desired looper thread.

If you want your runnable to be running asynchronously, just make your own thread to take charge of running and
remember to `resolve` or `reject` the result.

While in `thenable` method, you should supply us a `resolver`` which can turn the promise result into another promise
just like Promise in javascript.

And, The Promise lib here also provide us a lot of features that js promise owns too. Here is the example:


```java


public class PromiseTest {

	public static void main(String...args) {
		Promise<Integer> p1 = Promise.make(new DirectFunction<Integer>() {

			@Override
			public void run(final Locker<Integer> locker) {
				new Thread() {
					public void run() {
						try {
							System.out.println("p1 is running");
							Thread.sleep(5000);
						} catch (InterruptedException e) {
							locker.reject(e);<commit_msg>delete a ` [skip travis]<commit_after>[![Build Status](https://travis-ci.org/tangye1234/Promise.png)](https://travis-ci.org/tangye1234/Promise)
A Promise for android
======================

A Promise library for android which follows Promise/A+ standard

[![Promise/A+](https://rawgithub.com/promises-aplus/promises-spec/master/logo.svg)](https://promisesaplus.com/ "Promise/A+")

Introduction
=============

Nearly, all android promise open-source projects offer us a tool, which has async-thread-execution being involved
into their component. I must say, it is good, since `AsyncTask` is just like that - executing tasks in
a pre-built task-executors, or let user provide one for `AsyncTask`. But I think, Promise should just focus on
async processing functions with callbacks, without making any extra thread or using executors to handle `runnable`
or `Callable` process.

The Promise lib here dose not do any thread-making stuff, or not depends on any executors. It just produce a
`Deferred` object, letting you decide when to `resolve` a deferred or `reject` a deferred. Then making `then` on
a desired looper thread.

If you want your runnable to be running asynchronously, just make your own thread to take charge of running and
remember to `resolve` or `reject` the result.

While in `thenable` method, you should supply us a `resolver` which can turn the promise result into another promise
just like Promise in javascript.

And, The Promise lib here also provide us a lot of features that js promise owns too. Here is the example:


```java


public class PromiseTest {

	public static void main(String...args) {
		Promise<Integer> p1 = Promise.make(new DirectFunction<Integer>() {

			@Override
			public void run(final Locker<Integer> locker) {
				new Thread() {
					public void run() {
						try {
							System.out.println("p1 is running");
							Thread.sleep(5000);
						} catch (InterruptedException e) {
							locker.reject(e);
{'fraction_non_alphanumeric': 0.10390946502057613, 'fraction_numerical': 0.00720164609053498, 'mean_word_length': 4.291156462585034, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2782475', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1044, 'n_words': 470}