Enroscar Async

Library for managing asynchronous operations via Android loaders with a nice API

Лицензия

Лицензия

Группа

Группа

com.stanfy.enroscar
Идентификатор

Идентификатор

enroscar-async
Последняя версия

Последняя версия

2.0-RC3
Дата

Дата

Тип

Тип

jar
Описание

Описание

Enroscar Async
Library for managing asynchronous operations via Android loaders with a nice API
Ссылка на сайт

Ссылка на сайт

https://github.com/stanfy/enroscar-async
Система контроля версий

Система контроля версий

https://github.com/stanfy/enroscar-async

Скачать enroscar-async

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.stanfy.enroscar/enroscar-async/ -->
<dependency>
    <groupId>com.stanfy.enroscar</groupId>
    <artifactId>enroscar-async</artifactId>
    <version>2.0-RC3</version>
</dependency>
// https://jarcasting.com/artifacts/com.stanfy.enroscar/enroscar-async/
implementation 'com.stanfy.enroscar:enroscar-async:2.0-RC3'
// https://jarcasting.com/artifacts/com.stanfy.enroscar/enroscar-async/
implementation ("com.stanfy.enroscar:enroscar-async:2.0-RC3")
'com.stanfy.enroscar:enroscar-async:jar:2.0-RC3'
<dependency org="com.stanfy.enroscar" name="enroscar-async" rev="2.0-RC3">
  <artifact name="enroscar-async" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.stanfy.enroscar', module='enroscar-async', version='2.0-RC3')
)
libraryDependencies += "com.stanfy.enroscar" % "enroscar-async" % "2.0-RC3"
[com.stanfy.enroscar/enroscar-async "2.0-RC3"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
com.android.support » support-v4 jar 22.2.1
com.stanfy.enroscar : enroscar-async-interface jar 2.0-RC3

Модули Проекта

Данный проект не имеет модулей.

Enroscar Async

Makes it easy to put your asynchronous operations behind Android's Loader.

Main abstraction here is Async which represents some asynchronous operation.

How it is used

Read our recipes page. Here is a quick overview.

Describe an asynchronous operation.

class Foo {
  @Load Async<String> loadGreeting(final String name) {
    return Tools.async(new Callable<String>() {
      public String call() {
        try { Thread.sleep(1000); } catch (InterruptedException ignored) { }
        return "Hello " + name;
      }
    });
  }
}

In this example we create a simple Callable and pass it to Tools.async method that constructs an Async implementation running our Callable in Android's AsyncTask.

An annotations processor generates an operator class FooOperator that can be used to start/cancel your operations or subscribe to their execution results. Use it!

// this an object that provides operations
Foo foo = new Foo();

// prepare the operator
// FooOperator is a generated class
FooOperator operator = FooOperator.build()
    .withinActivity(activity)
    .operations(foo)
    .get();

// subscribing
operator.when().loadGreetingIsFinished()
    .doOnResult(new Action<String>() {
      @Override
      public void act(final String greeting) {
        Log.i("Async", "Greeting loaded: " + greeting);
      }
    });

// starting
operator.loadGreeting();

// cancelling
operator.cancelLoadGreeting();    

Note that working with an operator you actually control an Android Loader. Hence, using it within an Activity or Fragment you do not care about their lifecycle. Actions you provide subscribing to operations will be automatically attached to running tasks during Activity recreation.

Download

Maven Central

Gradle

compile 'com.stanfy.enroscar:enroscar-async:{latestVersionHere}'
// annotation processor should be added to 'provided' configuration
// it will not be included to your apk
provided 'com.stanfy.enroscar:enroscar-async-compiler:{latestVersionHere}'

To use it with RxJava you'll also need

compile 'com.stanfy.enroscar:enroscar-async-rx:{latestVersionHere}'
compile 'com.netflix.rxjava:rxjava-core:{latestVersionHere}'

License

 Copyright 2011-2015 Stanfy Corp.

 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.
com.stanfy.enroscar

Stanfy

Версии библиотеки

Версия
2.0-RC3
2.0-RC2
2.0-RC1
1.0.0
1.0-RC1