Comments (2)
Could you clarify your question with an example(s)?
from needle.
struct AddressesView<ViewModel>: View where ViewModel: AddressesViewModelProtocol {
@ObservedObject var viewModel: ViewModel
var detailBuilder: AddressDetailBuilder
var body: some View {
NavigationView {
List(viewModel.addresses) { address in
NavigationLink(destination: detailBuilder.addressDetailView) {
AddressRow(address: address)
}
}
.navigationTitle("Address List")
}
}
}
Maybe it is meant like this.
How would you pass the selected address down the line here to AddressDetailView
?
Of course you can keep it somewhere globally or in shared instances, but for cases like this it seems to be a bit over the top.
So is there any way to pass values ?
Maybe like this ?
import NeedleFoundation
import SwiftUI
protocol AddressDetailDependency: Dependency {
var addressRepository: AddressRepository { get }
}
class AddressDetailComponent: Component<AddressDetailDependency>, AddressDetailBuilder {
func addressDetailViewModel(selectedId: UUID) -> AddressDetailViewModel {
AddressDetailViewModel(repository: dependency.addressRepository, selectedId: selectedId)
}
func addressDetailView(selectedId: UUID) -> AnyView {
AnyView(
AddressDetailView(viewModel: addressDetailViewModel(selectedId: selectedId))
)
}
}
protocol AddressDetailBuilder {
func addressDetailView(selectedId: UUID) -> AnyView
}
from needle.
Related Issues (20)
- Proper usage of shared to avoid memory cycles HOT 5
- Generated Code doesn't work with package specification
- Getting double results HOT 4
- How to resolve dependency cycle? HOT 2
- Failed to read source paths from list file at iOS HOT 1
- Very high compile times in release mode for our largest app
- Needle's parsing of Component's properties is going "too deep"
- Runtime error with "properly generated needle code" HOT 2
- Improve Optional Dependencies HOT 3
- Internal properties of Components should be ignored
- Needle Cocoapods spec is outdated
- Needle Usage for Integration testing
- SPM product 'NeedleFoundation' required by package 'xxx' target 'xxx' not found. HOT 1
- public properties HOT 3
- Apple M1: "Some dependencies are missing" HOT 2
- Sample MVVM project is not compiling HOT 1
- The property is not passed from the parent to the child HOT 1
- Showing Recent Issues 💩 Some dependencies are missing, please look at the warnings above for the list.
- needle generate malfunctioning HOT 3
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 needle.