Simple, lightweight, modular components to help conjure your app architecture

Related tags

Testing magic
Overview

Magic

Magic

Simple, lightweight, modular components and utilities to help conjure your app architecture. Built with Kotlin coroutines to provide flexible asynchronous behavior.

Series

Kotlin CoroutineScopes by default are useful, but cannot control the order of execution of added coroutines and do not have much debugging behavior. Series solves these problems by providing cohesive APIs for executing coroutines in different orders and viewing running coroutines.

val series = QueueSeries() //Executes added coroutines one at a time
val firstJob = series.addJob { delay(20) println("#1 done") }
val secondJob = series.addJob { delay(10) println("#2 done") }

//prints #1 done, then #2 done

ViewModel

Most ViewModel libraries focus more on state abstraction than developer efficiency. However, Magic's ViewModel API simplifies the process of making a ViewModel down to short, readable lines of code. It comes with its own CoroutineScope, observable refresh system, and embeds a series for more efficient workflows.

class MyViewModel: ViewModel() {
  var name by state("")
  var age by state(0)

  fun uploadInfo() = series.add {
    model.uploadInfo(name, data)
  }
  
  init {
    series = CancelTentativeSeries() //Prevents multiple calls from starting multiple operations
  }
}

Status

A opinionated data structure for tracking the progress of operations. It comes with four different variants: NotStarted, Loading, Success and Issue.

StatusViewModel

An extension of ViewModel that smoothly integrates Status. StatusViewModel automatically bundles status states together (via the status map) for simple maintainability and readability. StatusViewModel also automatically creates Status objects from running code and updates status states.

class MyStatusViewModel: StatusViewModel<MyStatusViewModel.Key>() {

  //Status states can be accessed by the View with viewModel[Key.Name] or viewModel.get(Key.Name)
  enum class Key { Name, Upload }

  var name by state("")
  var age by state(0)

  //Validates the user's name and records the result (without intermediary loading) in the "Name" status
  fun validateName() = series.add {
    status(Key.Name, setLoading = false) {
      if(name.isEmpty()) error("Name cannot be empty")
    }
  }

  //Uploads user data and tracks its progress in the "Upload" status
  fun upload() = series.add {
    if(get(Key.Name) is Success) status(Upload) {
      model.uploadInfo(name, age) //Assumes model function throws an error if it fails
    }
  }
}

Coming Soon!

  • Native bindings to use ViewModels within iOS and Android apps
  • More examples and use-cases to demonstrate Series, ViewModel, Status and StatusViewModel
  • More primitives to solve structural problems in Kotlin Multiplatform
You might also like...
Very simple Morse API text translator. Mainly to do some testing with jitpack, API development etc.

Very simple Morse text translator API. Far from finish or even being reliable. Use for single sentence. Mainly to test github dependency for Android

YASNAC (short for Yet Another SafetyNet Attestation Checker) is an Android app that demonstrates SafetyNet Attestation API.

YASNAC YASNAC (short for Yet Another SafetyNet Attestation Checker) is an Android app that demonstrates SafetyNet Attestation API. YASNAC is written w

MyTaxi - App consuming myTaxi api to show taxi vehicles or otherwise on a map
MyTaxi - App consuming myTaxi api to show taxi vehicles or otherwise on a map

MyTaxi App App consuming myTaxi api to show taxi vehicles list on google maps. T

Lbc-test-app - Test Android Senior Leboncoin

Test Android Senior Leboncoin 🤖 Mathieu EDET Overview Min API version : 24 This

📚  Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.
📚 Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.

Android Components Architecture in a Modular Word Android Components Architecture in a Modular Word is a sample project that presents modern, 2020 app

📚  Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.
📚 Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.

Android Components Architecture in a Modular Word Android Components Architecture in a Modular Word is a sample project that presents modern, 2020 app

📚  Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.
📚 Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.

Android Components Architecture in a Modular Word Android Components Architecture in a Modular Word is a sample project that presents modern, 2020 app

📚  Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.
📚 Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.

Android Components Architecture in a Modular Word Android Components Architecture in a Modular Word is a sample project that presents modern, 2020 app

📚  Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.
📚 Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.

Android Components Architecture in a Modular Word Android Components Architecture in a Modular Word is a sample project that presents modern, 2020 app

Modular and customizable Material Design UI components for Android

Material Components for Android Material Components for Android (MDC-Android) help developers execute Material Design. Developed by a core team of eng

 🍲Foodium is a sample food blog Android application 📱 built to demonstrate the use of Modern Android development tools - (Kotlin, Coroutines, Flow, Dagger 2/Hilt, Architecture Components, MVVM, Room, Retrofit, Moshi, Material Components).  🍲Foodium is a sample food blog Android application 📱 built to demonstrate the use of Modern Android development tools - (Kotlin, Coroutines, Flow, Dagger 2/Hilt, Architecture Components, MVVM, Room, Retrofit, Moshi, Material Components). FunFacts is an example of Modular architecture
FunFacts is an example of Modular architecture

FunFacts FunFacts is an example of Modular architecture This Project is built using Kotlin,we will use in this App : Modular architecture Dependency I

Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin Gradle DSL.

SampleCompose Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin

Starter-Android-Library - Starter Android Library is an Android Project with Modular Architecture.
Starter-Android-Library - Starter Android Library is an Android Project with Modular Architecture.

Starter-Android-Library - Starter Android Library is an Android Project with Modular Architecture.

Clean Architecture Modular Project: MVI + Jetpack Compose + Coroutines + Flows + Hilt + UnitTests
Clean Architecture Modular Project: MVI + Jetpack Compose + Coroutines + Flows + Hilt + UnitTests

NyTimes for Clean Architecture The purpose of this project is to consolidate some of the learned insights throughout the years about the Clean Archite

:movie_camera: Movie discovery app showcasing Android best practices with Google's recommended architecture: MVVM + Repository + Offline support + Android Architecture Components + Paging library & Retrofit2.
:movie_camera: Movie discovery app showcasing Android best practices with Google's recommended architecture: MVVM + Repository + Offline support + Android Architecture Components + Paging library & Retrofit2.

Popular Movies Stage 1 + Stage 2 Discover the most popular and top rated movies playing. Movies data fetched using themoviedb.org API. ✨ Screenshots M

With MVVM Architecture pattern using Android Architecture Components This is a sample app demonstrating Youtube player animation using constraint layout
With MVVM Architecture pattern using Android Architecture Components This is a sample app demonstrating Youtube player animation using constraint layout

Youtube UI/UX Animation This is a sample app demonstrating Youtube UX/UI animation using ConstraintLayout.It implements the Keyframe Animation feature

🛒A Minimal Expense E-Commerce App built to demonstrate the use of modern android architecture components [Navigation, Room, MotionLayout, etc..] with MVVM Architecture. ✔
🛒A Minimal Expense E-Commerce App built to demonstrate the use of modern android architecture components [Navigation, Room, MotionLayout, etc..] with MVVM Architecture. ✔

E-Store A Simple E-Commerce App 📱 built to demonstrate the use of modern android architecture component with MVVM Architecture 🏗 . Made with love ❤️

Owner
TeraThought
TeraThought
Kotlin wrapper for React Test Renderer, which can be used to unit test React components in a Kotlin/JS project.

Kotlin API for React Test Renderer Kotlin wrapper for React Test Renderer, which can be used to unit test React components in a Kotlin/JS project. How

Xavier Cho 7 Jun 8, 2022
Linkester is an Android library that aims to help Android developers test their deep links implementation.

Linkester Linkester is an Android library that aims to help Android developers test their deep links implementation. The idea is to have a new launche

Ahmad Melegy 79 Dec 9, 2022
Raccoon is a lightweight response mocking framework that can be easily integrated into the Android UI tests.

Raccoon Medium Articles Checkout these article to get more insights about this library: How to integrate this in your Android Test Why Raccoon? There

Joseph James 52 Aug 15, 2022
Lightweight service for creating standalone mock, written in pure Kotlin with Netty container.

MockService The lightweight service for creating a standalone mock, written in pure Kotlin with Netty container. The service allows getting config fil

null 2 Oct 28, 2021
Android library that allows you to run your acceptance tests written in Gherkin in your Android instrumentation tests.

Green Coffee Green Coffee is a library that allows you to run your acceptance tests written in Gherkin in your Android instrumentation tests using the

Mauricio Togneri 227 Nov 21, 2022
Control and manage Android devices from your browser.

Warning This project along with other ones in OpenSTF organisation is provided as is for community, without active development. You can check any othe

STF 12.7k Jan 6, 2023
Easily scale your Android Instrumentation Tests across Firebase Test Lab with Flank.

Easily scale your Android Instrumentation Tests across Firebase Test Lab with Flank.

Nelson Osacky 220 Nov 29, 2022
A Kotlin Android library for heuristics evasion that prevents your code from being tested.

EvadeMe An Android library for heuristics evasion that prevents your code from being tested. User Instructions Add the maven repository to your projec

Chris Basinger 29 Dec 26, 2022
Setup CheckStyle, FindBugs, PMD and Lint for your Android project easily

android-quality-starter setup CheckStyle, FindBugs, PMD and Lint for your Android project easily This project adds gradle setup for quality tools ment

Piotr Wittchen 29 Sep 27, 2022
Project for testing intern candidate simple level

RickAndMorty-TestTask Тестовый проект 'Гайд по мультфильму Рик и Морти' для практикантов начального и продвинутого уровня. Структура проекта Структура

null 0 Nov 18, 2021