Closed ian-r-rose closed 4 years ago
It looks like we need node
typings in datastore
:
$ tsc --build
lerna ERR! yarn run build exited 1 in '@phosphor/datastore'
lerna ERR! yarn run build stdout:
$ tsc --build
../signaling/src/index.ts(609,41): error TS2304: Cannot find name 'setImmediate'.
Hey @ian-r-rose here is an example of connecting a stateless example to a state store:
import React from 'react'
import { state, sequences } from 'cerebral'
import { connect } from '@cerebral/react'
export default connect(
{
foo: state`foo`,
onClick: sequences`onClick`
},
function MyComponent({ foo, onClick }) {
return <div onClick={() => onClick()}>{foo}</div>
}
)
I'll take a look at this to see how the integration looks so far.
An example of specifying data locations for a widget to render a cell: https://github.com/ian-r-rose/jupyterlab/blob/e7f55cb40056cd75fda71aa43527cfbe1c79b14f/packages/cells/src/data.ts#L77-L91 In this case, the cell has a reference to a top-level record, as well as to a table of outputs.
An example of listening to for changes to particular fields: https://github.com/ian-r-rose/jupyterlab/blob/e7f55cb40056cd75fda71aa43527cfbe1c79b14f/packages/codemirror/src/editor.ts#L139-L154
An example of updating a particular record: https://github.com/ian-r-rose/jupyterlab/blob/e7f55cb40056cd75fda71aa43527cfbe1c79b14f/packages/cells/src/data.ts#L217-L226
Published @phosphor/datastore@0.8.0
.
Thanks for the review @blink1073! My thinking on a good signature for these functions has shifted a bit over in jupyterlab/jupyterlab#6871, so I'll probably make a follow up.
This adds some helper utilities for getting, updating, and listening to data in the datastore.
TableLocation
,RecordLocation
, andFieldLocation
.Datastore.withTransaction
helper which wraps a callback inbeginTransaction
/endTransaction
.These are currently statics in a
Datastore
namespace, since that's how I've been using them in JLab, but some of them could be moved onto the datastore class itself.