sahandnayebaziz / stateview Goto Github PK
View Code? Open in Web Editor NEWUIViews that update themselves when your data changes, like React.
License: MIT License
UIViews that update themselves when your data changes, like React.
License: MIT License
CocoaPods
is an awesome tool and make our life really easier, but there are some devs who still don't know how to use them.
It would be cool to add the Manual installation guide in your README.md
. You can take a look at my iOS Readme Template to see how you can do it.
Once the next version of Xcode is out of beta, I will go through and make StateView compatible with Swift 3. Any help is of course appreciated!
Hi, very excited about the promise of StateView
but it seems like it's not quite working correctly for me. Here's what I have:
import StateView
struct STStashStateViewLabelKey: StateKey {
var hashValue: Int = 1
}
class STStashChildView: StateView {
override func render() {
print("rendering STStashChildView")
let label = UILabel()
label.text = self.prop(withValueForKey: STStashStateViewLabelKey()) as! String
place(label, key: "label") { (make) in
make.center.equalTo(self)
}
}
override func viewWillUpdate(newState: [String : Any?], newProps: [StateViewProp]) {
print("viewWillUpdate in STStashChildView: \(newProps)")
}
}
class STStashStateView: StateView {
override func render() {
print("rendering STStashStateView")
let labelView = place(STStashChildView.self, key: "labelContainerView1") { (make) in
make.center.equalTo(self)
}
labelView.prop(forKey: STStashStateViewLabelKey(), is: self.state["text"] as! String)
let labelView2 = place(STStashChildView.self, key: "labelContainerView2") { (make) in
make.center.equalTo(self)
}
labelView2.prop(forKey: STStashStateViewLabelKey(), is: "Same Text" as! String)
}
override func viewWillUpdate(newState: [String : Any?], newProps: [StateViewProp]) {
print("viewWillUpdate in STStashStateView: \(newProps)")
}
}
And I initiate state change like that somewhere else in my code:
let stashStateView = STStashStateView(parentViewController: self)
view.addSubview(stashStateView)
stashStateView.setRootView()
stashStateView.state = ["text": "some new text value"]
after stashStateView
state changes I get viewWillUpdate
and render
calls in STStashStateView
and in both STStashChildView
s even though only one of them suppose to change due to new props but another one still renders "Same Text"
unchanged. Seems like the diff
doesn't work correctly or am I missing something?
It seems like a great idea that bringing react concept to native ios app.
So i would like to try StateView. Since I code mostly Objective-C for OS X, I am curious if StateView works with them.
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.