All Projects → akane → Akane

akane / Akane

Licence: mit
Lightweight native iOS MVVM framework

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Akane

San
A fast, portable, flexible JavaScript component framework
Stars: ✭ 4,514 (+4806.52%)
Mutual labels:  framework, mvvm, component
Mvvmframe
🏰 MVVMFrame for Android 是一个基于Google官方推出的Architecture Components dependencies(现在叫JetPack){ Lifecycle,LiveData,ViewModel,Room } 构建的快速开发框架。有了MVVMFrame的加持,从此构建一个MVVM模式的项目变得快捷简单。
Stars: ✭ 218 (+136.96%)
Mutual labels:  mvvm, viewmodel, component
Cascade
A modern library for creating user interfaces.
Stars: ✭ 50 (-45.65%)
Mutual labels:  mvvm, component
Mvvmrecurve
MVVM框架, 这个架构支持RestFul风格的Api和GraphQL,你可以根据自身需求添加recurve-retrofit2-support库(RestFul)或recurve-apollo-support库(GraphQL)实现相应的支持。 该架构同时使用纯Kotlin开发,但是你也可以在Java中使用它。
Stars: ✭ 51 (-44.57%)
Mutual labels:  framework, mvvm
Apprun
AppRun is a JavaScript library for developing high-performance and reliable web applications using the elm inspired architecture, events and components.
Stars: ✭ 1,087 (+1081.52%)
Mutual labels:  framework, component
Androidroom
Android example to show how to use Room to access SQLite database on device for reading and writing data. This example also shows how to use LiveData and ViewModel with Room to build reactive, well performing and easy to maintain applications.
Stars: ✭ 36 (-60.87%)
Mutual labels:  mvvm, viewmodel
Wanandroid
Jetpack MVVM For Wanandroid 最佳实践 !
Stars: ✭ 1,004 (+991.3%)
Mutual labels:  mvvm, viewmodel
Tdcapp
Sample app which access the TDC (The Developer's Conference) REST API.
Stars: ✭ 55 (-40.22%)
Mutual labels:  mvvm, viewmodel
Modelassistant
Elegant library to manage the interactions between view and model in Swift
Stars: ✭ 26 (-71.74%)
Mutual labels:  mvvm, viewmodel
Moviefinderusingmvvm Android
🔥 MVVM + Clean Architecture + Best Practices | 🍿Movie Finder is a sample Android application 📱to search movies using OMDb API which is built to demonstrate use of Modern Android development tools - (Kotlin, Coroutines, Kodein, Architecture Components, MVVM, Retrofit, Gson, Material Components) 😊😊😉
Stars: ✭ 66 (-28.26%)
Mutual labels:  mvvm, viewmodel
Android Architecture Components Mvvm Retrofit Java
This repository contains Android Architecture Components ( LiveData , View Model and MVVM pattern with retrofit for consuming rest api )
Stars: ✭ 63 (-31.52%)
Mutual labels:  mvvm, viewmodel
Easychatandroidclient
EasyChat是一个开源的社交类的App。主要包含消息、好友、群组等相关的IM核心功能。部分界面参照了QQ、微信等相关社交APP。EasyChat APP整体采用MVVM模式,基于JetPack(Lifecycle,LiveData,ViewModel,Room)构建
Stars: ✭ 64 (-30.43%)
Mutual labels:  mvvm, viewmodel
Jcnavigator
A decoupled navigator framework of jumping between modules or apps for iOS development.
Stars: ✭ 33 (-64.13%)
Mutual labels:  framework, component
Mvvmhabitcomponent
👕基于MVVMHabit框架,结合阿里ARouter打造的一套Android MVVM组件化开发方案
Stars: ✭ 857 (+831.52%)
Mutual labels:  mvvm, component
Royjs
Royjs is only 4.8kb mvvm framework for React
Stars: ✭ 49 (-46.74%)
Mutual labels:  framework, mvvm
Kodein Mvvm
Example app using Kodein for dependency injection with MVVM and Architecture Components
Stars: ✭ 26 (-71.74%)
Mutual labels:  mvvm, viewmodel
Awesome Android Kotlin Apps
👓 A curated list of awesome android kotlin apps by open-source contributors.
Stars: ✭ 1,058 (+1050%)
Mutual labels:  mvvm, viewmodel
Neutronium
🚀 Build .NET desktop applications using HTML, CSS and javascript.
Stars: ✭ 1,190 (+1193.48%)
Mutual labels:  framework, mvvm
Base Mvvm
App built to showcase basic Android View components like ViewPager, RecyclerView(homogeneous and heterogeneous items), NavigationDrawer, Animated Vector Drawables, Collapsing Toolbar Layout etc. housed in a MVVM architecture
Stars: ✭ 18 (-80.43%)
Mutual labels:  mvvm, viewmodel
Mvvmforms
Repository for MvvmForms
Stars: ✭ 19 (-79.35%)
Mutual labels:  mvvm, viewmodel

Akane

CocoaPods Carthage compatible Build Status

Akane is a iOS framework that helps you building better native apps by adopting an MVVM design pattern.

Head up to our example if you want to see a framework real use-case.

NOTE: Current version (0.30) is in beta. Click here if you want documentation for latest stable release (0.20.0).

Main Goals
😅 Safety: minimize bad coding practices as much as possible
🔧 Feature-Oriented: adding and maintaining features is easy and, yes, safe
🔠 Component-Oriented: each visual feature you want to add to your app is a Component (smart or dumb)
✂️ fine-grained Separation of Concerns, which means:
👯 Much less merge conflicts
😎 A better understanding of your code

Smart components are composed of:

  • ComponentViewController
  • ComponentViewModel
  • ComponentDisplayable

(New in 0.19!) Dumb components are simply composed of a Displayable and do not have an associated ViewModel.

Why Akane, Or MVVM versus iOS MVC

iOS developers tend to write all their code into a unique and dedicated ViewController class. While this may have been OK some years ago, today's app codebases grow bigger and bigger. Maintaining a single, huge, ViewController file is a dangerous operation which often results in unpredictable side effects.

Akane makes you split your code into small components which are composed of multiple classes.

Model

The Model is the layer containing the classes that model your application business.

Songs, Movies, Books: all those classes or structs belong to this layer. They should contain no reference to any UIKit or Akane component.

struct User {
  enum Title: String {
    case sir
    case master
  }

  let username: String
  let title: Title
}

Dumb component

Dumb component is not bound to a specific state but can still be updated with raw data.

It is represented by Displayable protocol.

class UserView: UIView, Displayable {
   @IBOutlet var title: UILabel!

   func bindings(_ observer: ViewObserver, params user: User) {
     self.title = UserFullNameConverter().convert(user)
   }
}

Smart component

Smart component represents a component who has a state defining its rendering:

  • State is represented using ComponentViewModel.
  • UI is represented using ComponentDisplayable.

ViewModel

The ViewModel is where all your business logic should be implemented.

Please, Keep it agnostic: no reference to any View or ViewController should be present in your ViewModel. Also, Prefer ViewModel composition over inheritance: split your code into multiple ViewModel, each one dealing with one business case and then create another ViewModel to aggregate all those logics.

import Akane

class UserViewModel : ComponentViewModel {
  let user: Observable<User>?
  var disconnect: Command! = nil

  init(user: User) {
    self.user = Observable(user)
    self.disconnect = RelayCommand() { [unowned self] in
      self.user.next(nil)
    }
  }

  func isConnected() -> Bool {
    return self.user != nil
  }
}

ComponentDisplayable

Data flow between a ViewModel and its ComponentDisplayable is bidirectional:

  • View <- ViewModel for data, through bindings
  • View -> ViewModel for actions, through commands: for instance, send a message or order a product.
import Akane

class LoggedUserView : UIView, ComponentDisplayable {
  @IBOutlet var userView: UserView!
  @IBOutlet var buttonDisconnect: UIButton!

  func bindings(observer: ViewObserver, params viewModel: UserViewModel) {
    observer.observe(viewModel.user).bind(to: self.userView)

    // bind 'disconnect' command with 'buttonDisconnect'
    observer.observe(viewModel.disconnect)
            .bind(to: self.buttonDisconnect)
  }
}

ComponentController

ComponentController protocol, makes the link between ComponentViewModel and its ComponentDisplayable.

Pass your ComponentViewModel to your ViewController to bind it to its view. You'll also need to declare your ComponentDisplayable as being Wrapped.

class LoggedUserViewController : UIViewController, ComponentController {
  typealias ViewType = LoggedUserView

  func didLoadComponent() {
    print("User component loaded")
    // here you can access self.viewModel
  }
}

extension LoggedUserView : Wrapped {
  typealias Wrapper = LoggedUserViewController
}

SceneController

ComponentController is unable to receive a ComponentViewModel from the "outside". So how to initialize a view hierarchy when, say, you push a view controller? That's the role of SceneController.

class HomeViewController : UIViewController, SceneController {
  typealias ViewType = HomeView
}

class AppDelegate {
  let context = MyContext() // In 0.30 beta, you have to create your own custom Context class

  application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {  
    let homeViewController = self.window.rootViewController as! HomeViewController
    homeViewController.renderScene(HomeViewModel(), context: self.context)

    return true
  }

  class MyContext : Context {
  }
}

Advanced usage

Collections

Akane supports displaying collections of objects in UITableViews and UICollectionViews. Please read the Collections.md documentation to know more.

Navbar

Navbars like views can be customized in Akane. All you have to do is to create a (Component)Displayable class and bind it to your navbar. Sounds complicated? Head over the example to see how you can do it easily!

Installation

Akane supports installation via CocoaPods and Carthage.

CocoaPods

pod 'Akane'

Akane builds on top of Bond for managing bindings. If you do want to use your own library (like RxSwift), you can use Akane core only:

pod 'Akane/Core'

Carthage

Add github "akane/Akane" to your Cartfile. In order to use Akane Bindings and Akane Collections, you should also append github "ReactiveKit/Bond".

United We Stand

Akane works great by itself but is even better when combined with our other tools:

  • Gaikan, declarative view styling in Swift. Inspired by CSS modules.
  • Magellan, routing solution to decouple UI from navigation logic.

Contributing

This project was first developed by Xebia IT Architects and has been open-sourced since. We are committed to keeping on working and investing our time in Akane.

We encourage the community to contribute to the project by opening tickets and/or pull requests.

License

Akane is released under the MIT License. Please see the LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].