lgessler / glam

(WIP) a webapp for language documentation
Eclipse Public License 2.0
40 stars 3 forks source link

Plain JS components for Document UIs #30

Closed lgessler closed 7 months ago

lgessler commented 9 months ago

Introduction

This epic proposes an API that would allow UI developers to make new UIs for documents without having to know anything about ClojureScript or Fulcro.

Background

The frontend is currently implemented in ClojureScript with Fulcro. For the near term, this is not going to change. (Though in the future, we may evaluate transitioning away from ClojureScript and Fulcro.)

Problem

ClojureScript and Fulcro are both fairly difficult to learn quickly and pretty much nobody will come to this project already knowing it. This makes it difficult for contributors to give us new UIs

Proposal

After document locks are implemented (#22), it will become feasible to implement a wrapper API around Fulcro that will abstract away all Fulcro concepts and give UI developers a normal-looking interface for interacting with Fulcro and the backend. This API would allow us to implement new UIs for documents using just plain React, which would greatly reduce the work necessary for someone to implement a UI for our frontend.

For example, we might provide a function with this signature:

function updateSpanValue(spanId, newValue) { /* ... */ }

This could provide consumer code like this:

// Called by some UI interaction
async function handleUpdateSpanValue(spanId, newValue) {
  // ... optimistically update UI ...
  let result = await updateSpanValue(spanId, newValue);
  if (!result.error) {
    // backend succeeded, probably do nothing
  } else {
    // there was an error--backtrack the optimistic update
  }
}

If concurrent editing were allowed, this approach would not necessarily work, since clients would not receive updates about edits made by any other clients. But since #22 will guarantee that no more than one writer will be active at a time for any given document, this simple approach will work.

One question, at least:

  1. Should this be supported just for Documents, or will we need this to exist for other views as well?

Child Issues

(List child issues here as they are created. This issue should not be closed until all child issues are closed.)

lgessler commented 7 months ago

Closing this since we're going to be chucking the existing frontend