You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The pain and anguish of using IndexedDB: problems, bugs and oddities
This gist lists challenges you run into when building offline-first applications based on IndexedDB, including open-source libraries like Firebase, pouchdb and AWS amplify (more).
Note that some of the following issues affect only Safari. Out of the major browsers, Chrome's IndexedDB implementation is the best.
Backing file on disk (WAL file) keeps growing (Safari)
When this bug occurs, every time you use the indexeddb, the WAL file grows. Garbage collection doesn't seem to be working, so after a while, you end up with gigabytes of data.
Random exceptions when working with a large number of indexeddb databases (Safari)
I often want to read Markdown documentation on Github — or proof-read my own documents — without staring at a backlit screen. Here's an easy way to print the files in a readable format.
Create a bookmarklet with the following code and give it the name "github print"
Go to the markdown view on Github of the file you want to print, e.g. Ripgrep's user guide
Click on the bookmarklet. Alternatively (in Chrome) type "github print" in the search bar, select the bookmarklet code with cursor keys if necessary and press enter.
Use the browser print feature to print the document, to a physical printer or (to save paper) to PDF on a reMarkable eInk tablet.
There are many reasons why people like Object-Oriented Programming, but personally, my main reason for the use of classes in TypeScript is making dependencies explicit and replaceable. For example, suppose you have a module, Calendar, which depends on another module, GCalClient - i.e. Calendar uses the functionality from GCalClient but not vice versa. The most straightforward way to write that code is by simply using the functionality from GCalClient when needed:
// calendar.ts
import {bookAppointment} from "google-calendar-client"
function createMeeting() {
While this detailed post is about the Amazon's so-called Leadership Principles, the general approach can be used
when interviewing for any company in talking about your experience.
For offline-first operation, browser apps cache data in an IndexedDb database. When the user makes a change while offline, they persist the change optimistically. When connectivity is restored, changes are synced to the server.
This pattern is well established today. However, given the possibility of opening the app in multiple tabs at the same time, we seem to be faced with a dilemma:
We allow users to use the app and to make changes in multiple tabs at the same time. But then two "threads" are writing to the same shared resource at the same time. Co-ordinating writes seems to be difficult.
To make things worse, while the localStorage API allows you to register a callback that fires whenever an item is changed outside the current tab, the IndexedDb API doesn't, at least not in a widely-available way.