{"id":16886687,"url":"https://github.com/alisoftware/formworkflow","last_synced_at":"2025-04-11T14:02:11.340Z","repository":{"id":137559966,"uuid":"49089440","full_name":"AliSoftware/FormWorkflow","owner":"AliSoftware","description":"A sample project to demonstrate how to use Promises to describe a workflow of Screens/ViewControllers","archived":false,"fork":false,"pushed_at":"2016-01-05T20:21:26.000Z","size":93,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T10:11:57.123Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AliSoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-05T20:01:06.000Z","updated_at":"2020-08-28T04:21:01.000Z","dependencies_parsed_at":"2023-03-21T19:52:27.098Z","dependency_job_id":null,"html_url":"https://github.com/AliSoftware/FormWorkflow","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AliSoftware%2FFormWorkflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AliSoftware%2FFormWorkflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AliSoftware%2FFormWorkflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AliSoftware%2FFormWorkflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AliSoftware","download_url":"https://codeload.github.com/AliSoftware/FormWorkflow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248412808,"owners_count":21099196,"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-13T16:40:46.670Z","updated_at":"2025-04-11T14:02:11.288Z","avatar_url":"https://github.com/AliSoftware.png","language":"Swift","readme":"# FormWorkFlow\n\nThis is a Proof-of-Concept sample projet to suggest how to implement a workflow of generic forms using Promises.\n\nBasically, the idea is to consider ViewControllers as functional boxes, taking inputs and returning a `Promise\u003cT\u003e` which will be fulfilled when the user has validated to screen.\n\nThen we can easily create a flow of ViewControllers by using the promise's `then` block to tell which VC should appear next in the flow.\n\nA simple, linear workflow could then look like this:\n\n```swift\n// The workflow of ViewControllers will be pushed in a\n// NavCtrl presented in a modal\nlet nc = UINavigationController()\nself.presentViewController(nc, animated: true, completion: nil)\n\n// This is quite clear from this code layout how the screens flow\nfirstly {\n  self.pushScreen1(nc)\n}\n.then {\n  self.pushScreen2(nc)\n}\n.then {\n  self.pushScreen3(nc)\n}\n.then {\n  self.pushScreen4(nc)\n}\n.recover { (error: ErrorType) -\u003e Void in\n  try self.handleCancellation(error)\n}\n.recover { e in\n  print(\"Wooops, something bad (other than a cancellation) happened: \\(e)\")\n}\n.always {\n  self.dismissViewControllerAnimated(true, completion: nil)\n  print(self.model)\n}\n```\n\nWhere the `pushScreenX(nc)` functions might look like this:\n\n```swift\nprivate func pushScreen1(nc: UINavigationController) -\u003e Promise\u003cVoid\u003e {\n    // Create the screen/VC\n    let form = FormViewController(…)\n    // Push it\n    nc.pushViewController(form, animated: false)\n    // Return a promise of fulfillment\n    // (which will be fired when the use validate the screen)\n    return form.promise()\n  }\n```\n\nSee `FormViewController.swift`'s code to see how the promise is created. In this VC's code, a tap on the `rightBarButtonItem` fulfills it while a tap on the `leftBarButtonItem` rejects it.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falisoftware%2Fformworkflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falisoftware%2Fformworkflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falisoftware%2Fformworkflow/lists"}