Skip to content

Live data

xcesco edited this page Dec 19, 2018 · 6 revisions

About Architecture Components, Live Data and View Model you will find tons of documentation and tutorials. A good place to start is always the official documentation.

Kripton since version 4, can generate live data and so it can be used with the other architectural components. If you want to generate a live data from a DAO simple define a method returning LiveData type.

An important thing: Kripton supports both Live Data pre-JetPack and Live Data included in Jet Pack suite. To configure Kripton to work with them see Annotation Processor Options

@BindDao(Person.class)
public interface DaoPerson0 {
  @BindSqlSelect
  LiveData<List<Person>> selectAll();
	
  @BindSqlInsert
  void insert(Person bean);
	
  @BindSqlUpdate(where ="id=${bean.id}")
  void update(Person bean);	
}

And its usage:

// we are in an activity#onCreate
LiveData<List<Person>> liveData = ds.getDaoPerson0().selectAll();
liveData.observe(this, persons -> System.out.println("*********** "+persons.size()));				

Kripton, at compile time, will generate all necessary code to manage live data. Note that there is a default executor thread pool to manage async task for live data. If you want to override this behaviour, at application startup, you can setup your executor using the right init method.

KriptonLibrary.init(contextValue, executorService);

Table of Contents

Query definition

Features

Relations

Multithread supports

Modularization

Annotations for data convertion

Annotations for SQLite ORM

Annotations for shared preferences

Clone this wiki locally