cyclejs-community/cycle-android

Name: cycle-android

Owner: Cycle.js Community

Description: A Cycle.js port for Android

Created: 2016-03-13 01:32:58.0

Updated: 2018-04-06 05:17:21.0

Pushed: 2016-08-30 07:15:02.0

Homepage:

Size: 160

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Cycle.js Android

Build Status

A Proof of Concept that ports the Cycle.js reactive concepts to Android. It currently uses Anvil for incremental UI updates, Retrofit for HTTP requests and, obviously, RxJava for the Observables implementation.

It's still alpha state, but already demonstrates that it can be achieved. The repo has a few demos: The classic Hello World, Counter, Github search and BMI Calculator. All have been ported from the Cycle.js Examples repository.

Usage

build.gradle

ile 'com.felipecsl:cycle-android:0.2.0'

MyActivity.java

ic class MyActivity extends AppCompatActivity {
Override protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_sample);
 app = (ViewGroup) findViewById(R.id.app);
 DomSource domSource = new DomSource(DomDriver.makeDomDriver(app));
 HttpSource httpSource = new HttpSource(HttpDriver.makeHttpDriver());
 Cycle.run(this::main, domSource, httpSource);


rivate Sinks main(Sources sources) {
 DomSink domSink = DomSink.create(sources.dom()
   .select(R.id.editName)
   .events("input")
   .map(ev -> ev.<EditText>view().getText().toString())
   .startWith("")
   .map(name -> (Anvil.Renderable) () ->
       xml(R.layout.vtree_helloworld, () ->
           withId(R.id.txtHelloWorld, () ->
               text("Hello, " + name)))));

   return Sinks.create(domSink);


See the Sample app for more examples.

License
Copyright (C) 2016 Felipe Lima

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.