Giter Site home page Giter Site logo

stateview's People

Contributors

sahandnayebaziz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stateview's Issues

Manual Installation

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.

Swift 3 Support

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!

Using StateView and StateKeys

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 STStashChildViews 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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.