Need help with nanotasks?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

fabiendevos
396 Stars 36 Forks Other 25 Commits 5 Opened issues

Description

Extremely light way to execute code in the background on Android. Alternative to AsyncTask.

Services available

!
?

Need anything else?

Contributors list

# 297,006
Java
Kotlin
15 commits
# 117,204
retrofi...
Groovy
nosql-d...
Kotlin
1 commit
# 41,152
compile...
applesc...
macbook
swift3
1 commit

NanoTasks

NanoTasks is an extremely light way to execute code in the background on Android. It is a wrapper arround AsyncTask that provides a simpler to use and more flexible API.

Notes

  • NanoTasks is meant to be extremely simple to use and leightweight. If you are looking for more features please have a look to RxJava or Bolt.
  • The onSuccess/onError callbacks won't be called if your context is null. No more NPE crashes because the Activity was destroyed (Although as some people pointed out this is not totally solved yet. I'm working on a better solution for the v2).

Usage

Tasks.executeInBackground(context, new BackgroundWork() {
    @Override
    public Data doInBackground() throws Exception {
        return fetchData(); // expensive operation
    }
}, new Completion() {
    @Override
    public void onSuccess(Context context, Data result) {
        display(result);
    }
    @Override
    public void onError(Context context, Exception e) {
        showError(e);
    }
});

Dependency

Gradle

groovy
compile 'com.fabiendevos:nanotasks:1.1.0'
Maven
xml

  com.fabiendevos
  nanotasks
  1.1.0

You can also download it directly from Maven Central repo.

Author

Fabien Devos - Twitter @fabien_devos - LinkedIn

License

NanoTask is licensed under the Apache 2 license (you can use it in commercial and open source projects).

Copyright 2015 Fabien Devos

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.