All Projects → Taig → Communicator

Taig / Communicator

Licence: mit
A monix wrapper for OkHttp

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to Communicator

Androidrapidlibrary
Android 快速开发库,主要想实现一条属于自己的开发框架。包括网络访问,数据,UI等等
Stars: ✭ 577 (+1597.06%)
Mutual labels:  okhttp
Okreplay
📼 Record and replay OkHttp network interaction in your tests.
Stars: ✭ 697 (+1950%)
Mutual labels:  okhttp
Avenuenet
AvenueNet 是一个基于 Retrofit 二次封装的网络请求库,使用 Rxjava 的链式调用方式,二次封装的目的是为了对请求数据的正确性以及错误状态做统一的处理,对 Retrofit 对象做管理,有点为业务而生的味道,并非纯正的网络请求库
Stars: ✭ 10 (-70.59%)
Mutual labels:  okhttp
Aosf
AOSF:全称为Android Open Source Framework,即Android优秀开源框架汇总。包含:网络请求okhttp,图片下载glide,数据库greenDAO,链式框架RxJava,组件路由ARouter,消息传递通信EventBus,热更新Tinker,插件化框架Replugin,文件下载FileDownloaer,图片选择PhotoPicker,图片滤镜/毛玻璃等特效处理,GIF图片展示控件,图片九宫格控件NineGridView,对话框Dialog,导航指示器ViewpagerIndicator,进度条ProgressWheel,下拉刷新SmartRefreshLayout,key-value高效数据存储MMKV等,应有尽有。
Stars: ✭ 601 (+1667.65%)
Mutual labels:  okhttp
Rxwebsocket
An auto reconnection-webSocket build with okhttp and rxJava
Stars: ✭ 678 (+1894.12%)
Mutual labels:  okhttp
Mvvmhabit
goldze: 本人喜欢尝试新的技术,以后发现有好用的东西,我将会在企业项目中实战,没有问题了就会把它引入到MVVMHabit中,一直维护着这套框架,谢谢各位朋友的支持。如果觉得这套框架不错的话,麻烦点个 star,你的支持则是我前进的动力!
Stars: ✭ 6,789 (+19867.65%)
Mutual labels:  okhttp
Retrofitclient
基于Retrofit2.x和Rxjava2.x封装的请求工具类(内含Retrofit2.x & rxjava1.x)
Stars: ✭ 532 (+1464.71%)
Mutual labels:  okhttp
Awesome Third Library Source Analysis
📖 Deep understanding of popular open source library source code (optimizing...)
Stars: ✭ 866 (+2447.06%)
Mutual labels:  okhttp
Coil
Image loading for Android backed by Kotlin Coroutines.
Stars: ✭ 7,469 (+21867.65%)
Mutual labels:  okhttp
Androidall
Android 程序员需要掌握的技术栈:数据结构算法、程序架构、设计模式、性能优化、插件化、热更新、Kotlin、NDK、Jetpack,以及常用的开源框架源码分析如 Flutter、Router、RxJava、Glide、LeakCanary、Dagger2、Retrofit、OkHttp、ButterKnife 等
Stars: ✭ 849 (+2397.06%)
Mutual labels:  okhttp
Retrofitcache
RetrofitCache让retrofit2+okhttp3+rxjava配置缓存如此简单。通过注解配置,可以针对每一个接口灵活配置缓存策略;同时让每一个接口方便支持数据模拟,可以代码减小侵入性,模拟数据可以从内存,Assets,url轻松获取。
Stars: ✭ 647 (+1802.94%)
Mutual labels:  okhttp
Wanandroid
🐔🏀【停止维护,已使用Jetpack+Mvvm重构】根据鸿神提供的WanAndroid开放Api来制作的产品级玩安卓App,采用Kotlin语言,基于Material Design+AndroidX +MVP+RxJava+Retrofit等框架开发,注释超详细,方便大家练手
Stars: ✭ 674 (+1882.35%)
Mutual labels:  okhttp
Okhttpparamsget
帮助你去获取params
Stars: ✭ 22 (-35.29%)
Mutual labels:  okhttp
Fast Android Networking
🚀 A Complete Fast Android Networking Library that also supports HTTP/2 🚀
Stars: ✭ 5,346 (+15623.53%)
Mutual labels:  okhttp
Mvvmhabitcomponent
👕基于MVVMHabit框架,结合阿里ARouter打造的一套Android MVVM组件化开发方案
Stars: ✭ 857 (+2420.59%)
Mutual labels:  okhttp
Android Zblibrary
🔥Android MVP 快速开发框架,做国内 「示例最全面」「注释最详细」「使用最简单」「代码最严谨」的 Android 开源 UI 框架。 🔥An Android MVP Framework with many demos, detailed documents, simple usages and strict codes.
Stars: ✭ 5,000 (+14605.88%)
Mutual labels:  okhttp
Easygank
💊 The project build framework based on the Rx series and MVP pattern.
Stars: ✭ 750 (+2105.88%)
Mutual labels:  okhttp
Tina
a powerful android network library base on okhttp
Stars: ✭ 32 (-5.88%)
Mutual labels:  okhttp
Kotlin Life
App界的一股清流 音视频vr应有尽有 完全按照Material design规范设计的App (written with java and Kotlin)
Stars: ✭ 864 (+2441.18%)
Mutual labels:  okhttp
Zsbpads
Material design、MVC、OKHttp、Glide、greendao 设计的一款面试题题库的app完整项目
Stars: ✭ 25 (-26.47%)
Mutual labels:  okhttp

Communicator

CircleCI codecov Maven License

A monix wrapper for OkHttp

Communicator provides a simple way to construct OkHttp requests as monix.Tasks which is equipped with a beautiful functional interface and comes with first class support for cancellation.

Installation

libraryDependencies ++=
    "io.taig" %% "communicator-request" % "3.5.1" ::
    "io.taig" %% "communicator-builder" % "3.5.1" ::
    Nil

Quickstart

import monix._; import eval.Task; import execution.Scheduler.Implicits.global
import io.taig.communicator._
import okhttp3.OkHttpClient
import scala._; import util._; import concurrent._; import duration._

// To build request tasks, an implicit OkHttpClient should be in scope
implicit val client = new OkHttpClient()

// Simple OkHttp request builder
val builder = new OkHttpRequestBuilder().url("https://github.com/")

// Construct a Task[Response] and parse it to a String
val request = Request(builder.build()).parse[String]

// Kick off the actual request
val response = request.runAsync
Await.result(response, 30.seconds)
// res4: io.taig.communicator.Response[String] =
// >>> https://github.com/
// [No headers]
// <<< 200 OK
// Server: GitHub.com
// Date: Fri, 31 Aug 2018 12:49:58 GMT
// Content-Type: text/html; charset=utf-8
// Transfer-Encoding: chunked
// Status: 200 OK
// Cache-Control: no-cache
// Vary: X-PJAX
// Set-Cookie: has_recent_activity=1; path=/; expires=Fri, 31 Aug 2018 13:49:58 -0000
// Set-Cookie: _octo=GH1.1.1880644452.1535719798; domain=.github.com; path=/; expires=Mon, 31 Aug 2020 12:49:58 -0000
// Set-Cookie: logged_in=no; domain=.github.com; path=/; expires=Tue, 31 Aug 2038 12:49:58 -0000; secure; HttpOnly
// Set-Cookie: _gh_sess=Y3RsdXRvTWFNZ0tZKy9hWlZ1Ujc4KzRYTlBuTm51bFJoWHN0TGZzQjJxa0hLQXJ4enhzcTgvOHhuOTFqWW9qcjhDalpML0UvWSt3NzVTWGYyOHIwL283Y0xsQXJkcnVHKy84Uk8zYnVsdmpxNnpoMG5MbXJucTBxNWs3ejI4MVBQO...

Usage

Communicator provides a thin layer around OkHttp using monix.Task to execute HTTP requests and monix.Observable for Phoenix Channels. To construct requests, the OkHttp builder API is used.

Building Requests

Use the OkHttp builder API to construct requests which are then lifted into io.taig.communicator.request.Request.

val headers = new OkHttpRequestBuilder().
    url("https://github.com/").
    header("X-API-Key", "foobar").
    build()

val request: Request = Request(headers)

Handling Responses

There are several ways to transform a Request to an executable Task[Response].

// Ignores response body
val ignoreBody: Task[Response[Unit]] = request.ignoreBody

// Parses response body to a String
val parse: Task[Response[String]] = request.parse[String]

Android

To use Communicator on the Android platform please extend your ProGuard rules by the following instructions:

proguardOptions ++=
    "-dontnote okhttp3.internal.**" ::
    "-dontnote monix.execution.internals.**" ::
    "-dontwarn io.circe.generic.util.macros.**" ::
    "-dontwarn monix.execution.internals.**" ::
    "-dontwarn okio.**" ::
    "-dontwarn org.jctools.**" ::
    "-dontwarn org.slf4j.**" ::
    Nil

You might also use existing platform Executors to provide a monix Scheduler:

import android.os.AsyncTask
import android.util.Log
import monix.execution.Scheduler

implicit val PoolScheduler: Scheduler = Scheduler {
    ExecutionContext.fromExecutor(
        AsyncTask.THREAD_POOL_EXECUTOR,
        t  Log.e("PoolScheduler", "Failure during asynchronous operation", t)
    )
}

Communicator 2.x

The scala.concurrent.Future predecessor of this library has been deprecated. You can still access the source and documentation.

Communicator 1.x

The Java predecessor of this library has been deprecated. You can still access the source and documentation.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].