Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Large cleanup

Choose a tag to compare

@Gozala Gozala released this 03 Jul 21:43
· 82 commits to master since this release

What's new

Migration to [email protected] proper

While back library started using flow type checker, but opted into via comment style annotations. At this point it made little sense to continue using commented syntax if anything it just made things more difficult for no benefit.

Factoring out driver

Interface definition between reflex and it's drivers has being part of reflex library itself, but that only made things difficult as driver implementations had to depend on reflex itself & update every time thing changed there. By factoring driver interface into own package allows for less frequent synchronization requirements between reflex & it's drivers.

Driver interface has also being simplified greatly. Reflex used to over-specify structure of the nodes but that provided no benefit for increased complexity. Now drivers have much looser interface & are able to represent node implementations as they're pleased.

A Farewell to FRP

Catching up with Elm's removing signals. Signals were always internal implementation details except they were used to bootstrap application event loops:

Before

import {init, update, view} from "./app"
import {start, Effects} from "reflex"
import {Renderer} from "reflex-virtual-dom-driver"

const renderer = new Renderer({target:document.body})
const app = start({init, update, view, flags:null})

app.view.subscribe(renderer.address)
app.task.subscribe(Effects.driver(app.address))

After

import {init, update, view} from "./app"
import {start, Task} from "reflex"
import {Renderer} from "reflex-virtual-dom-driver"

const renderer = new Renderer({target:document.body})
const app = start({init, update, view, flags:null}, ({view, task}) => {
  renderer.render(view)
  Task.perform(task)
})

Experimental support of subscriptions has also being added, but for now they're not documented as the API is not fully fleshed out, but you can look at the source & start playing around with them if you like.

Breaking changes

Startup API has changed

Before

import {init, update, view} from "./app"
import {start, Effects} from "reflex"
import {Renderer} from "reflex-virtual-dom-driver"

const renderer = new Renderer({target:document.body})
const app = start({init, update, view, flags:null})

app.view.subscribe(renderer.address)
app.task.subscribe(Effects.driver(app.address))

After

import {init, update, view} from "./app"
import {start, Task} from "reflex"
import {Renderer} from "reflex-virtual-dom-driver"

const renderer = new Renderer({target:document.body})
const app = start({init, update, view, flags:null}, ({view, task}) => {
  renderer.render(view)
  Task.perform(task)
})

No more signals

If you used to create your own signals or map / reduce them they are gone, so you'll need to stop doing that.

No more driver

If you used reflex driver code you should look at reflex-driver it has being factored out.

Better type inference

Before we used to have our own Never type which got replaced by flow built-in empty type, migration will require some work but mostly should be smooth. New flow also catches far more errors and code has being updated to provide better code coverage which means far more errors maybe caught after update.