Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: content api for frontend events from backend, ui updates and reset command #101

Merged
merged 9 commits into from
May 8, 2024

Conversation

daretodave
Copy link
Contributor

resolves #14

introduces the context.content(Yes) operation

content can have events attached to them e.g

  const no = context.content(`<button>No</button>`)
  
  no.on('click', () => {
    context.out('\n\nDeclined reset')
    context.finish(0)
  })

or more complex -

  context.out('Reset all mterm settings, commands, modules?\n')

  const yes = context.content(`<button>Yes</button>`)

  context.out('|')

  const no = context.content(`<button>No</button>`)

  no.on('click', () => {
    context.out('\n\nDeclined reset')
    context.finish(0)
  })

  yes.on('click', async () => {
    context.out('\n\nCleaning...')

    await remove(context.workspace.folder)

    context.out('\nReloading...')

    await context.workspace.load()
    context.out('- settings reloaded \n')

    await context.workspace.commands.load(context.workspace.settings)
    context.out('- commands reloaded \n')

    await context.workspace.reload(RunnerWindow)
    context.out('- window reloaded \n')

    context.finish(0)
  })

image

content can also be updated e.g (a clock)

  context.out('Time: ')

  let minute = 0
  let second = 0

  const M = context.content(`<span>00</span>`)

  context.out(':')

  const S = context.content(`<span>00</span>`)

  setInterval(() => {
    S.update(`<span>${`${second++}`.padStart(2, '0')}</span>`)
  }, 1000)
  setInterval(() => {
    M.update(`<span>${`${minute++}`.padStart(2, '0')}</span>`)
  }, 1000 * 60)

image

@daretodave daretodave merged commit d8fbce5 into main May 8, 2024
2 checks passed
@daretodave daretodave deleted the feature/runner-ui-hooks branch May 8, 2024 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add utilities to return react components in custom commands
1 participant