donut / OCamURL-client

A web client for OCamURL-server URL shortener written in ReasonML.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OCamURL Client

A web client for OCamURL-server URL shortener.

Why ReasonML

Throughout development and after release, a few have asked why I chose Reason instead of OCaml since both can be transpiled to JavaScript and I already wrote the server in OCaml. Reason just has better syntax for JS interop. I definitely prefer OCaml's syntax, but Reason is not that different and it makes working in React much easier.

Building

$ yarn install
$ yarn build
$ cp config.example.js config.js
# Set your OCamURL-server settings in config.js.

Point your web server to [/public/index.html].

Areas for Improvement

This was my first project in ReasonML and it shows. I am sure there is more room for improvement than I can see at this point. However, here are some big items.

Replace Reductive with Reducer Components

I decided to use Reductive, an implementation of Redux in ReasonML, just over halfway into the project. For some reason the built-in reducers in ReasonReact just weren't clicking for me at the project level. I've used Redux in TypeScript/JS projects and so I modeled my use of Reductive on that. However, with that experience came clarity of how to use ReasonReact's reducer components to fill the same hole.

Probably the first major refactor should be to move the state handling to reducer components, passing down state and reducer functions as props. This will make it easier to see which components modify state and what state they actually care about. Global state can live in the root component.

Look into HOC for GraphQL Queries

Reason Apollo basically only has one built-in way to handle quries and mutations: higher-order components (HOC). This hasn't clicked for me, yet. The main issues I see are how side-effects and state updates are handled with HOC queries and mutations. Some more details on my confusion. And someone else who's running into trouble.

For now I've built around this with the Apollo.Request functor, which returns non-component modules for queries and mutations. It also includes special error handlers for the unconventional way OCamURL-server returns errors.

Project Expectations

This is a project for use at RightThisMinute. There is no promise of support or continued work in this public repo. It is being released mainly to benefit those who are starting out in ReasonML. It's likely a poor example, but being simpler may help make some things clear. This isn't to say we're not accepting issues and pull requests, just know that we may have selfish motivations in what we integrate.

About

A web client for OCamURL-server URL shortener written in ReasonML.

License:MIT License


Languages

Language:OCaml 88.8%Language:CSS 8.3%Language:JavaScript 2.0%Language:HTML 0.9%