Comments (1)
Hi @rvangraan,
You should be able to do that yourself with extensions, like this:
protocol DynamicProtocol {}
extension Dynamic: DynamicProtocol {}
Then you can declare an array of Dynamics of any generic type:
var dynamicValues = [DynamicProtocol]()
dynamicValues.append(Dynamic<Int>(0))
dynamicValues.append(Dynamic<String>("hi"))
That being said, for whatever reason you might need this, I'm not sure it's good approach. First of all, type information will be lost, so you'll need to cast to right type before binding:
(dynamicValues[1] as! Dynamic<String>) ->> nameLabel
Additionally, if you replace a dynamic element in the array, the binding will be lost. For example, if you do:
dynamicValues[1] = Dynamic<String>("Tim")
Then updating that new dynamic would not propagate to name label because that new Dynamic is not bound to it.
I'd strongly recommend against doing all this.
Thanks
PS You should always declare your Dynamics as constants, using let
keyword:
private let dynDescription = Dynamic(description)
private let dynNetAmount = Dynamic(Money())
private let dynVatAmount = Dynamic(Money())
from bond.
Related Issues (20)
- Best way to interact with UIRefreshControl ?
- Cannot emulate VC lifecycle event HOT 1
- Feed() using collection view's sizeForItemAt delegate selector crashes on iOS 13
- MutableObservableArray2D replace items can't use performdiff
- Cocoapods latest version HOT 1
- Project file uses SRCROOT; should be PROJECT_DIR HOT 2
- Correct way to update MutableObservableArray2D from signals
- No (understandable) migration documentation for NSTableView binding
- Incorrect operator precedence in OutlineViewBinder.(_:,isExpandable:)
- Regarding .Framework file.
- Xcode build error: Header 'ReactiveKit-Swift.h' not found
- Cannot not build source code from the latest version on Xcode 12.3
- Wrong generic use of ObservableArray/MutableObservableArray?
- viewForSupplementaryElementOfKind and bidirectional binding HOT 1
- Control Event not triggered when setting data inside viewModel to textField
- Installation problems Xcode Version 12.4 (12D4e)
- Incorrect MutableObservableArray difference
- Error building app with Xcode 12.5 HOT 4
- Swift Package Manager Dynamic Libraries
- Unable to run in simulator on M1 Macs HOT 6
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 bond.