How to use the st/config.readConfig function in st

To help you get started, we’ve selected a few st examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github leafo / sightreading.training / static / js / components / song_editor.es6 View on Github external
constructor(props) {
    super(props)

    let song = this.props.song

    this.notesCountInputRef = React.createRef()
    this.beatsLengthInputRef = React.createRef()
    this.codeInputRef = React.createRef()

    this.fieldUpdaters = {
      code: e => this.updateCode(e.target.value)
    }

    let initial = song
    if (!song) {
      initial = readConfig("wip:newSong")
      // render the initial song
      if (initial) {
        window.setTimeout(() => {
          if (this.state.code == initial.code) {
            if (this.props.onCode) {
              this.props.onCode(initial.code)
            }
          }
        }, 0)
      }
    }

    this.state = {
      song,
      newSong: !song,
      loading: false,
github leafo / sightreading.training / static / js / components / app.es6 View on Github external
constructor(props) {
    super(props)
    let device = readConfig("defaults:outputDeviceType") || "none"
    let midiOutputChannel
    if (device == "internal") {
      midiOutputChannel = SampleOutput.getInstance()
    }

    this.state = {
      outputDeviceType: device,
      forwardMidi: readConfig("defaults:forwardMidi") == 1,
      midiOutputChannel
    }

    if (navigator.requestMIDIAccess) {
      navigator.requestMIDIAccess().then(
        midi => {
          this.setState({midi: midi})
          this.loadDefaultSettings()
        },
        error => console.warn("failed to get MIDI"))
    }
  }
github leafo / sightreading.training / static / js / components / app.es6 View on Github external
loadDefaultSettings() {
    let defaultMidiInput = readConfig("defaults:midiIn")
    if (defaultMidiInput) {
      let idx = 0
      for (let input of this.midiInputs()) {
        if (input.name == defaultMidiInput) {
          this.setInput(idx)
        }
        idx++
      }
    }
  }
github leafo / sightreading.training / static / js / components / app.es6 View on Github external
constructor(props) {
    super(props)
    let device = readConfig("defaults:outputDeviceType") || "none"
    let midiOutputChannel
    if (device == "internal") {
      midiOutputChannel = SampleOutput.getInstance()
    }

    this.state = {
      outputDeviceType: device,
      forwardMidi: readConfig("defaults:forwardMidi") == 1,
      midiOutputChannel
    }

    if (navigator.requestMIDIAccess) {
      navigator.requestMIDIAccess().then(
        midi => {
          this.setState({midi: midi})
          this.loadDefaultSettings()
github leafo / sightreading.training / static / js / components / song_editor.es6 View on Github external
updateWip(update) {
    if (!this.state.newSong) {
      return false
    }

    let wip = readConfig("wip:newSong") || {}
    wip = Object.assign({}, wip, update)
    writeConfig("wip:newSong", wip)
    return true
  }