colineberhardt / avalon Goto Github PK
View Code? Open in Web Editor NEWA prototype binding framework for iOS - to support the MVVM pattern
A prototype binding framework for iOS - to support the MVVM pattern
Need to work out how this will be achieved, e.g. how to create a placeholder while images are loaded? what happens when cells are recycled?
See:
This should be supported by:
"ViewModelBase isn't doing KVO properly, you need to use a context parameter to ensure superclasses get called properly. It's not an issue given the current class hierarchy, but you're better off doing it the right way now instead of debugging it later, should the superclass change in the future. http://stackoverflow.com/a/11917449"
Remembering to correctly prefix their names (if necessary)
Because Avalon makes use of a number of Objective-C APIs (e.g. KVO, associated properties) it imposes a number of uncomfortable constraints. It would be great to be able to remove these at some point. Hopefully as the Swift language evolves, this will become possible!
bindingContext
ObservabeArray
has to be a class, rather than a struct, because it is stored in associated properties. Swift structs cannot be bridged to Objective-C@objc
in order that they can be used as associated properties (probably worth a review to check this is necessary in all cases)Similar to the knockout concept, very useful for master-detail
The UIControl binding is disposed, but UIView is not.
Perhaps it would be better to have an observable array as an adapter over a strongly types swift array?
Due to the implementation of the overridden didMoveToWindow:
method, it's currently possible for a delegateMultiplexer to be set as its own delegate. This in turn causes an infinite loop, and stack overflow.
There's a partial hotfix in: sammyd@a6bbd3a
if delegate !== delegateMultiplexer {
delegateMultiplexer.delegate = delegate
self.delegate = delegateMultiplexer
}
I think there are other code paths that could cause the same effect - maybe it would make sense for the multiplexer to reject a delegate value of itself?
UISegmentedControl has a bug, if you remove an item the selected item index is decremented. This causes quite a few issues with Avalon, where the selection index is maintained.
Line 39 in 9fae570
Affects
If you bind the selected index first, then the items, the initial selection state is incorrect:
segmentedControl.bindings = [Binding(source: "selectedOption", destination: "selectedSegmentIndex", mode: .TwoWay),
Binding(source: "options", destination: "segments")]
Need to cache the value.
It should be possible to specify that a bounds property is converted to a string via a formatter:
When you pick a new value, an exception is thrown, something to do with the delegate multiplexer. First spotted in this commit:
As suggested by @sammyd - I think this sound viable.
This can be done by subscribing to the EditingDidEnd control event.
An exception is thrown here:
Avalon/Avalon/ViewModelBase.swift
Line 14 in 2be121f
Provide binding support to the following:
UIView subclasses
UIControl subclasses
Consider using custom operator functions to streamline Binding creation:
infix operator >| {} // One-way binding
infix operator |<>| {} // Two-way binding
func >| (source: String, destination: String) -> Binding
{
return Binding(source: source, destination: destination, mode: .OneWay)
}
func |<>| (source: String, destination: String) -> Binding
{
return Binding(source: source, destination: destination, mode: .TwoWay)
}
// bind the controls to the view model
// searchBar.bindings = [Binding(source: "searchText", destination: "text", mode: .TwoWay),
// Binding(source: "searchAction", destination: "searchAction")]
//
// tableView.bindings = [Binding(source: "places", destination: "items"),
// Binding(source: "placeSelectedAction", destination: "selectionAction")]
searchBar.bindings = [
"searchText" |<>| "text",
"searchAction" >| "searchAction"
]
tableView.bindings = [
"places" >| "items",
"placeSelectedAction" >| "selectionAction"
]
I neat idea via @ijoshsmith
Currently all bindings must be added before the bindingContext is set in order to create the binding.
These need to have they bindings evaluated.
One advantage is that it already has a registry concept built-in ..
Avalon/Avalon/ValueConverter.swift
Line 14 in 2be121f
Affects
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.