Suspender

Suspender generates wrapper classes around normal java classes and exposes its methods as suspend functions

Лицензия

Лицензия

Группа

Группа

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

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

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

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

1.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Suspender
Suspender generates wrapper classes around normal java classes and exposes its methods as suspend functions
Ссылка на сайт

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

https://github.com/josesamuel/Suspender/
Система контроля версий

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

https://github.com/josesamuel/Suspender/

Скачать suspender

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

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

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
com.squareup : javapoet jar 1.9.0
com.squareup : kotlinpoet jar 1.5.0

runtime (2)

Идентификатор библиотеки Тип Версия
com.josesamuel : suspender-annotations jar 1.0.0
com.google.auto : auto-common jar 0.8

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

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

Suspender

Suspender generates wrapper classes around normal java classes and exposes its methods as suspend functions

Consider an existing class that performs a long running process as part of its function -

/**
 * An office
 */
class Office {
	....
	
    fun addEmployee(employee: Employee) {
        //validate through some long running process
        
        //add
        employees.add(employee)
    }
}

Suspender allows you to call the above function safely from your coroutine without blocking it

    //This calls will block
    office.addEmployee(employee)

	//This is suspended call
    office.asSuspendable().addEmployee(employee)

All you have to do is specify which all existing classes needs to have wrappers generated!

Simply annotate an interface with @Suspender and specify all the classes that needs to be wrapped.

@Suspender(classesToWrap = [
    Office::class, 
    School::class
])
interface XXX

That's it!

Annotations

  • @Suspender Annotate on any interface/class to specify the classes that needs to be wrapped. For each of the class X specified, a wrapper class X_SuspendWrapper will be generated along with an extension function X.asSuspendable()

Getting Suspender

Gradle dependency

dependencies {

    implementation 'com.josesamuel:suspender-annotations:1.0.0'
    kapt 'com.josesamuel:suspender:1.0.0'
}

License

Copyright 2020 Joseph Samuel

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.

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

Версия
1.0.0