Comments (12)
It seems like the PR by @bencochran fixes my problem. I'm happy to close the issue if that's alright with you.
Thanks for the help!
from workflow.
It looks like your ViewController
is missing the addChild(container)
and container.didMove(toParent:)
, resulting in UI events not being correctly delivered to the text field and the text field delegate methods in HelloViewController
never being called. Put up a PR that appears to fix the issue on my end.
from workflow.
I'm not very familiar with Swift so this is just a guess, but this line looks suspicious to me:
.rendered(with: context, key: UUID().description)
Is that generating a new UUID every time? If so, all your child workflows will be restarted on every render pass, and the ones from the previous render pass will be stopped, which is why their sinks stop working.
from workflow.
You are indeed correct. UUID()
generates a new universally unique identifier every time. That might be the problem. If I am correct, the key must be unique between all of the children. So I could use, for example, the name of the workflow, such as TextWorkflow
or Child 1
, Child 2
, etc?
I'll give this a try and let you know if it works.
Thank you for the quick reply!
from workflow.
That should work. As long as the key is derived from something that identifies the child workflow consistently across render passes.
from workflow.
Yeah, you’ll need stable (and unique) keys between renders. I’d consider making some kind of identifier part of the items held in WorkflowData
(like maybe var workflows: [(identifier: String, workflow: AnyWorkflow<…>]
, or a struct to wrap that up).
One other thing you’re going to need is to implement screenDidChange
in your GraphViewController
. When your workflow tree rerenders, the new root screen will be handed to that method to update itself and its children (calling update(screen:environment:)
on each child DescribedViewController with its appropriate screen). Which also means you’ll need to keep those child view controllers around for use somewhere (another good use for the stable identifiers defined above).
from workflow.
Also, if I want to render children, should I use child.rendered(with:key:)
or context.render(workflow:key:outputMap:)
? What is the difference between the two?
from workflow.
I finally figured it out. It turns out the sink wasn't firing because of the way I was presenting my ContainerViewController
. Instead of using present(_:animated:completion:)
, I was hosting the view controller as a child like this:
let container = ContainerViewController(
workflow: GraphWorkflow(data: WorkflowData(key: "Root"))
)
let containerView = container.view!
self.view.addSubview(containerView)
containerView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
containerView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
containerView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
containerView.topAnchor.constraint(equalTo: self.view.topAnchor),
containerView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor)
])
What I should have used was as simple as:
let container = ContainerViewController(
workflow: GraphWorkflow(data: WorkflowData(key: "Root"))
)
present(container, animated: true, completion: nil)
Once I swapped out the initial code with the new version, everything started working. However, I would like to have the ContainerViewController
embedded in another UIViewController
, via an embed segue or just programatically. Is there any way to make that work and still have the sink operational?
from workflow.
Is there a sample project where this bug repros? Happy to look into it if there is.
Is the block that's calling sink.send()
getting called? Is the Action.apply()
getting called?
from workflow.
Is there a sample project where this bug repros? Happy to look into it if there is.
Is the block that's calling
sink.send()
getting called? Is theAction.apply()
getting called?
Currently, I am using Square Workflow in a private project. I'm afraid I can't share the source code of that project. I do, however, have a test/demo project that consists of some simple code that essentially reproduces the bug in question. I can upload the demo project to GitHub if you would like to experiment with it. I would also make sure to mark the problem areas with comments and explanations.
from workflow.
Thanks @AlexandruIstrate! That'll be perfect.
from workflow.
I have created a repository with the demo project. Essentially, in the file ViewController.swift
you have the choice between two methods (1 and 2). They are marked so that you know what each does. The difference between the two is that in one, the ViewController
is getting presented modally over the top and in the other it gets embedded as a child.
Link to the repo: SquareWorkflowDemo
from workflow.
Related Issues (20)
- Sonatype releases are broken
- Consider making convenience builder functions inline HOT 1
- Proposal: Introduce `WorkflowUICommon` HOT 3
- Get TracingDiagnosticListener out of the main module, clean up the DiagnosticListener API HOT 1
- Kotlin runtime Flow of renderings should be a StateFlow
- What happened to our site search? HOT 2
- Extract Swift code into dedicated repository and remove from this repo.
- Extract Kotlin code into dedicated repository and remove from this repo.
- Introduce renderWorkflowIn overload for starting from state for tests HOT 2
- Rename master branch to trunk HOT 3
- Kotlin workers are started even if scope is cancelled
- Fix deploy_website script to deploy from extracted repos HOT 1
- Question: strategies for a global workflow (redux style data store) for data that is central to the app? HOT 3
- Documentation needed for backstacks specifically
- Design a common solution to text editing HOT 1
- Update docs to mention Worker Key
- Production Release
- Fill in Coming Soon pages
- Add an entry to userguide/core-patterns about using PropsT for one-shot workflows
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from workflow.