Questions tagged [moya]

Open source network abstraction layer that encapsulates calling Alamofire directly.

Features of Moya include:

  • Compile-time checking for correct API endpoint accesses.
  • Lets you define a clear usage of different endpoints with associated enum values.
  • Treats test stubs as first-class citizens so unit testing is super-easy.
207 questions
6
votes
1 answer

How to add parameters in Moya?

So I've been working on this tutorial by Gary Tokman to build a restaurant viewing app and it's great. From the beginning to the end, everything works properly and well. The aim is to change or add a parameters and include either 'term' or…
moyo.clive22
  • 61
  • 1
  • 2
6
votes
4 answers

Cache Handling with Moya

We have implemented Moya, RxSwift And Alamofire as pods in our project. Does anyone know how you gain control of the cache policies per url request using this tech? I have read through quite a few of the issues on Moya's GitHub page but still…
AMAN77
  • 6,218
  • 9
  • 45
  • 60
6
votes
2 answers

Writing unit tests for a Moya request

I want to start writing test cases for all my Moya requests. How can I test a simple Moya .get request generated from Swift?
6
votes
2 answers

How do I detect change in internet connection on iOS, delegate style?

I need a function to run only when the system detects there is no internet connection, then another function to run when the system detects an internet connection. I'm thinking of something like this: func onInternetConnection() { //Enable…
Berry
  • 2,143
  • 4
  • 23
  • 46
6
votes
2 answers

How to get error statusCode from `MoyaError`?

I'm using a Moya, Moya_ModelMapper and RxSwift to perform network requests. Here is my example code: let provider = RxMoyaProvider() let observable: Observable = provider.request(.register(firstName: "", lastName:…
kamwysoc
  • 6,709
  • 2
  • 34
  • 48
6
votes
1 answer

Can only add notification blocks from within runloops

i've some crashs on this part of code : SRNetwork.provider .request(SRService.postData(user_id: userId)) .mapArray(STrain.self) .observeOn(ConcurrentDispatchQueueScheduler.init(queue: SDispatchQueue.dataTrain.getQueue())) …
Makaille
  • 1,636
  • 2
  • 24
  • 41
5
votes
2 answers

Updating periodically with RxSwift

I use the following setup to retrieve objects (e.g. GitHub issues) from an API. This works fine. let provider: RxMoyaProvider let issues: Driver<[IssueViewModel]> init(provider: RxMoyaProvider) { self.provider = provider …
tilo
  • 14,009
  • 6
  • 68
  • 85
4
votes
2 answers

How do I fix the error: "Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ffee0761ed8)"

I am using swift to build an app in Xcode. it builds fine, but when it runs, it stops and gives me an error on the line a declare my delegate(this line: "weak var delegate: LocationActions?") in LocationService.swift. Here is the error: Thread 1:…
user10081458
4
votes
1 answer

Is it possible to map to a "fallback" Decodable using RxSwift and Moya?

I am using RxMoya for the network layer of my app and I'm having a case where the server can either send the expected response (let's say a User), or an error object, both with status code 200. For example: { "name": "john doe", "username":…
phi
  • 10,634
  • 6
  • 53
  • 88
4
votes
1 answer

correct use of retryWhen operator with RxSwift 4.0.0

with RxSwift 3.6.1 I made this extension to ObservableType to get a new token after an error request: public extension ObservableType where E == Response { public func retryWithToken() -> Observable { return retryWhen { error ->…
Davide Bettio
  • 63
  • 1
  • 5
4
votes
3 answers

Moya change URL

I try to call to Google Places Api using Moya and have a problem with URL. Maya change characters in my URL. In this case for example before character ? adds %3f and change , for %2C. When I copy and paste this address into my web browser, I receive…
PiterPan
  • 1,760
  • 2
  • 22
  • 43
4
votes
3 answers

How to use Moya to download file

Usual I use Alamofire & Moya/RxSwift & ObjectMapper to analysis object But now add a demand. My app need download file. I have use Alamofire.download(urlString, to: destination) Temporary solved the problem but It's not elegant. I want use Moya…
Tony
  • 59
  • 1
  • 5
4
votes
2 answers

RxSwift pagination

I can't manage to get this solution to work: https://github.com/liuznsn/RxMoyaPaginationNetworking Maybe someone can tell me where is the mistake. The loading variable never goes to false. I guess the issue is in the request observable, but I can't…
pluck
  • 179
  • 2
  • 13
3
votes
0 answers

Will horizontalAccuracy of CLLocation have value infinity in some cases?

I am currently working on a crash issue reported by a customer. From the crash logs seems like our app is trying to send location data to backend in JSON format, and it throws Invalid number value (infinite) in JSON write because JSON does not…
Bruce
  • 2,357
  • 5
  • 29
  • 50
3
votes
1 answer

Moya+Alamofire POST request is getting timeout when switching between apps or going into background

I am calling an API before switching app or going into background but when I switch to foreground within 5-10 seconds that API request gets timedout. I am using Moya+Alaomofile with RxSwift. I have tried increasing the SessionConfiguration timeout…
Bmacin
  • 235
  • 1
  • 12
1
2
3
13 14