Fifthtry

How to make http requests in Realm?

Release Date: 19-Feb-2020

Commit.

Current Realm have a variety of ways to do backend requests, sometimes using Realm provided facilities, and sometimes using elm/http.

The key problems with this scattered approach:

With standardisation we also get a major benefit: we pave way for service worker based offline support at Realm level. Every GET request made using method described here get auto cached and will work when offline.

This project is about standardising every backend request scenario.

We have identified two key modes.

PageOrError

You submit a form, get back API error (to update the form in current page), or a page as response, to be rendered. For example login page, it shows a form, you submit, you either get form error (error against each field), or you should get the next page.

DataOrError

You call an API, get field error or json response. This is less preferred: all data should be loaded with the page comes. If you are implementing search etc, prefer Page Or Error mode, keep going to next page, instead of calling backend api and generating page.

What would be good use case for this mode? At fifthtry we use this mode for as you type username check in create username flow. We do not want to interrupt the user’s typing, so we can not do PageOrError, so we do this instead.

Network And Other Errors

In the above two modes, we have an error handler path, which receives error messages for server error. Eg a login form normally gets error messages against fields "username" or "password", but it can also receive error against "__all__", which represents string representation of network or server error.

One point to note is that in most cases you do not want to handle this error. You want to have a global app error handler, which features retry etc, so you do not have to build it in all your forms.

Table Of Content

What is Realm?

A Bit On Motivation

Routing is Hard

What does Realm do?

Backend Data And Type Safety

Tutorial

Quick Start Realm Tutorial

In Depth Tutorial (not ready)

Nix
Shell
Doit
Hello Rust
Hello Elm
Hello Static Files
Hello Server Side Rendering
Pre-Commit Hooks

Routing, Request And Response

Frontend, Data, Navigation, And APIs

How To Guides

File Upload

Backend: S3 File Upload
Authenticated File Serving
Frontend: Uploading Files From Elm

How to use storybook?

How to implement “loading..”?

Docs

Realm.In

Realm.Storybook.Story

realm::In

realm::Context

realm::Result

realm.magicSlice

realm::RequestConfig

Environment Variables

Internals - Only for Realm Developers, not Users

“Realm DATA”
iFrame Controller
Shutdown Routine
Testing Internals

Change Log

Get Realm Starter Working

Transparent Offline Feature

How to make http requests in Realm?

Development

Replay Testing

Tutorial: ToDo App

Realm Testing

Enhance Realm Starter

Double Load Issue

Deploy To Heroku Button

End failure

Realm-Starter Github Template

Proposal: Tracker And Visit

Proposal: Activity Store

Proposal: Bundling

Proposal: Retry On Network Error

Storybook: Editable JSON

Storybook: Notes

Storybook: Reference

Backlog

Readings

Change Log

How to Publish

Testing

Code Snippets

Skip rustfmt For Some Section

Close Modal Dialog When Clicked Outside

Ignoring Lints In Python

Ignoring Lints (clippy and rustc warnings) In Rust

Handle DateTime in Rust & Elm

Handle CiText value read in Rust

Transport Enum Type to and fro Rust/Elm through JSON