From e0699eed72c5682bd2395ba4299ff69933c83d48 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 19 Feb 2023 14:39:02 +0100 Subject: Be more precise configuring chords --- src/view/play.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/view/play.ts') diff --git a/src/view/play.ts b/src/view/play.ts index b85e505..4abc4ec 100644 --- a/src/view/play.ts +++ b/src/view/play.ts @@ -1,4 +1,4 @@ -import { h, withVar, Html } from 'lib/rx' +import { h, withState, Html } from 'lib/rx' import * as Options from 'view/options' import * as Chord from 'chord' @@ -9,19 +9,19 @@ interface ViewParams { export function view({ options }: ViewParams): Html { const initChords: Array<[string, string]> = [['', ''], Chord.generate(options), Chord.generate(options)] - return withVar(initChords, (chords, updateChords) => - withVar(undefined, (beat, updateBeat) => { + return withState(initChords, chords => + withState(undefined, beat => { let chordBeat = 1 const interval = setInterval(() => { if (chordBeat === options.beatsPerChord) { - updateChords(xs => { + chords.update(xs => { xs.shift() xs.push(Chord.generate(options)) return xs }) chordBeat = 1 } else { - updateBeat(_ => undefined) + beat.update(_ => undefined) chordBeat += 1 } }, 60 / options.bpm * 1000) -- cgit v1.2.3