Shutdown Routine

In Realm.js you will see a function shutdown(), here is why we bother with this shutdown routine: our elm app controls the document body, and we can simply start the next app when we are switching (we used to do this, but we found some issues).

Problem is the event handlers of the app that we are trying to unload/shutdown. Elm does not have .destroy() corresponding to .init(), to cleanly remove all the click etc event handlers we have attached to our old app’s view. Similarly the subscriptions, can still keep on firing after the app is unloaded, leading to bugs and confusion.

The way it works is, Realm.App wraps the client application, and Realm.App receives the shutdown message we send: window.realm_app.ports.shutdown.send(null).

When Realm.App gets this message, it stops calling client application’s view, instead it returns an empty view with a DOM element with unique ID (appShutdownEmptyElement). When Elm’s virtual DOM library comes across this empty DOM, it deletes all the DOM, by cleanly removing all event handlers.

Further Realm.App does not call subscriptions, so Elm removes subscription related event handlers too.

Table Of Content

What is Realm?

A Bit On Motivation

Routing is Hard

What does Realm do?

Backend Data And Type Safety


Quick Start Realm Tutorial

In Depth Tutorial (not ready)

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..”?









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?


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



Change Log

How to Publish


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