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

[POC] end-user-programming "REPL" exploration #233

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

@szymonkaliski
Copy link
Collaborator

@szymonkaliski szymonkaliski commented Nov 13, 2018

This PR is proof-of-concept for REPL for connecting from laptop sidecar machine to running capstone instance.

Basic running: install, restart capstone, and then (on sidecar machine):

$ cd src/apps/repl-cli
$ ./capstone-cli "capstone://Workspace/..." # grab the workspace from running capstone instance

Welcome to Capstone CLI [hash]
>>>

You can now execute one-off commands within the Capstone env:

# not too exciting
>>> 2 + 2
4

# dump the current store state
>>> Content.store
{ ... }

# snap all cards to grid
>>> Content.once(Content.rootBoardUrl, change => change(doc => {
    Object.keys(doc.cards).forEach(key => {
      const snap = 100
      doc.cards[key].x = Math.round(doc.cards[key].x / snap) * snap
      doc.cards[key].y = Math.round(doc.cards[key].y / snap) * snap
    })

    return doc
  })
)

I'm also experimenting with idea of hooks to attach behaviours, the only existing hook right now is hooks.onCardDragEnded but this allows us to have snap-to-grid happen after each drag is completed (hook is execute within doc.change context so we can update card directly):

>>> hooks.onCardDragEnded = (card) => {
  const snap = 100
  card.x = Math.round(card.x / snap) * snap
  card.y = Math.round(card.y / snap) * snap
}

Putting this out so you can play with it before Friday's show&tell where I hope to demo this functionality and share some notes.

This probably shouldn't be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant