Giter VIP home page Giter VIP logo

autocalculatemathstatement's Introduction

Auto Calculate Math Statement

Sample project of iOS

  1. Using MVVM:
  • With Wireframe for navigating from / to a screen
  • With Service for all request used in a screen

  1. Using Bond for Binding (https://github.com/DeclarativeHub/Bond)

  2. Supported by API of MathJS (https://api.mathjs.org)


Current project is using One-Way and Two-Ways Binding, binding placed in View:

  1. Main binding
// in View
func setupBinding() {
    textField.reactive.text.bidirectionalBind(to: viewModel.model.statement)
    viewModel.model.result.bind(to: resultLabel)
    viewModel.showLoading.bind(to: self) { vc, _ in
        vc.showLoading()
    }
    viewModel.hideLoading.bind(to: self) { vc, _ in
        vc.hideLoading()
    }
}
  1. Two-Ways Binding

Everytime user typing in the textField in "View", the value of statement in "ViewModel" also changed.

// in View
textField.reactive.text.bidirectionalBind(to: viewModel.model.statement)

And then, when user click the button "CLEAR", it trigger function reset() in "ViewModel". This function clear the statement in "ViewModel", and also change the textField in "View".

// in View
@IBAction func onTapClearButton(_ sender: Any) {
    viewModel.reset()
}
// in ViewModel
func reset() {
    model.statement.value = ""
    model.result.value = ""
}
  1. One-Way Binding

result in ViewModel change resultLabel in View:

// in View
viewModel.model.result.bind(to: resultLabel)
  1. Example of using signal to trigger loading in "View" from "ViewModel"
// in View
viewModel.showLoading.bind(to: self) { vc, _ in
    vc.showLoading()
}
viewModel.hideLoading.bind(to: self) { vc, _ in
    vc.hideLoading()
}

Contain Unit Tests:

Demo:


Special thanks to OVO-iOS-Team

autocalculatemathstatement's People

Contributors

revoreva avatar

Stargazers

 avatar  avatar

Watchers

 avatar

autocalculatemathstatement's Issues

One-Way-Binding

Hypothesis: One Way is can be done within the feature that has View for only as input / output

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.