{"id":16906951,"url":"https://github.com/ashfurrow/reactivemoya","last_synced_at":"2025-04-11T15:36:39.463Z","repository":{"id":36136810,"uuid":"40440507","full_name":"ashfurrow/ReactiveMoya","owner":"ashfurrow","description":null,"archived":false,"fork":false,"pushed_at":"2015-09-07T16:43:09.000Z","size":7725,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-25T11:49:18.484Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ashfurrow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-09T15:15:12.000Z","updated_at":"2022-01-29T10:50:26.000Z","dependencies_parsed_at":"2022-09-05T11:01:16.130Z","dependency_job_id":null,"html_url":"https://github.com/ashfurrow/ReactiveMoya","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashfurrow%2FReactiveMoya","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashfurrow%2FReactiveMoya/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashfurrow%2FReactiveMoya/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashfurrow%2FReactiveMoya/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ashfurrow","download_url":"https://codeload.github.com/ashfurrow/ReactiveMoya/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248432201,"owners_count":21102334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T18:45:22.385Z","updated_at":"2025-04-11T15:36:39.437Z","avatar_url":"https://github.com/ashfurrow.png","language":"Swift","readme":"# ReactiveMoya\nA simpler way to use Moya+ReactiveCocoa.\n\nInstallation\n------------------------\n####Carthage\nAdd this line to your `Cartfile`:\n```\ngithub \"Moya/ReactiveMoya\"\n```\nand run `carthage update`\n\nUsage\n------------------------\n\nReactiveMoya is the Moya you know, with the RAC interfaces you're used to. `ReactiveMoyaProvider` immediately returns a `SignalProducer` or `RACSignal` that you can subscribe to or bind or map or whatever you want to\ndo. To handle errors, for instance, we could do the following:\n\n```swift\nprovider.request(.UserProfile(\"ashfurrow\"))\n    .subscribeNext({ (object) -\u003e Void in\n        if let response = object as? MoyaResponse {\n            image = UIImage(data: response.data)\n        }\n    }, error: { (error) -\u003e Void in\n        println(error)\n    })\n```\n\n```swift\nprovider.request(.UserProfile(\"ashfurrow\"))\n  |\u003e start(error: { error in\n    println(error)\n  }, \n  next: { (object: MoyaResponse) in\n    image = UIImage(data: object.data)\n  })\n```\n\nIn addition to the option of using signals instead of callback blocks, there are\nalso a series of signal operators that will attempt to map the data received \nfrom the network response into either an image, some JSON, or a string, with \n`mapImage()`, `mapJSON()`, `mapJSONArray()`, `mapJSONDictionary()`, and `mapString()`, respectively.\nIf the mapping is unsuccessful, you'll get an error on the producer or signal. You also get handy methods for\nfiltering out certain status codes. This means that you can place your code for \nhandling API errors like 400's in the same places as code for handling invalid \nresponses. \n\nThe example above becomes:\n```swift\nprovider.request(.UserProfile(\"ashfurrow\"))\n    .mapImage()\n    .subscribeNext({ (object: AnyObject) in\n        if let image = object as? UIImage {\n            // Do something with the image\n        }\n    },\n    error: (error: NSError) in\n        println(error)\n    })\n```\n\n```swift\nprovider.request(.UserProfile(\"ashfurrow\"))\n    |\u003e mapImage()\n    |\u003e start(error: { (error: NSError) in\n        println(error)\n    },\n    next: { (image: UIImage) in\n        // Do something with the image\n    })\n  \n```\n\nRunning the Example\n------------------------\nTo run the example:\n\n####Using Carthage\n\nNavigate to the root of the directory and run `carthage bootstrap`\n\nOpen the Example project and build\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashfurrow%2Freactivemoya","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fashfurrow%2Freactivemoya","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashfurrow%2Freactivemoya/lists"}