-
Notifications
You must be signed in to change notification settings - Fork 152
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
feat: rows
and rowsSync
API on Shape
#1897
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
One comment would be that we may want to change more of the tests to use .rows
and .rowsSync
as they are the user facing APIs.
I agree but that was my point about the I'm happy to open a new PR with the full breaking change refactor. |
Ah yes. I would argue we should make this braking change now. But maybe this so that its more extendable in future: export type ShapeData<T extends Row<unknown> = Row> = Map<string, T>
export type ShapeChangedCallback<T extends Row<unknown> = Row> = (data: { // <-- new wrapper object
value: ShapeData<T> // <-- can still get the "value"
rows: T[] // <-- now have the rows
}) => void so that it can used with: shape.subscribe(({ rows }) => {
// Do stuff...
}); We can then add additional metadata as further props to the callback in future. @KyleAMathews what do you think? |
Sidebar: rowsSync and valueSync — is this synchronous access to the rows/value? Ie wrap up Because if so “sync” is a bit overloaded/ambiguous in our context. |
I do think that the combination of That being said, the |
Yeah, maybe |
Ok so based on this feedback I'm applying @samwillis suggestion (that is still a breaking change but keeps both the |
I like your api suggestion @samwillis 👍 And yeah, we're making a number of breaking changes now — so toss this on the pile. This is a great time to fine-tune the API to a huge extent as we have enough breadth and depth of experience to make better judgements on stuff like this. |
✅ Deploy Preview for electric-next ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
should be ready to merge now - updated the changeset to reflect the breaking change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
neat!
Fixes #1888
I've added both a
rows
androwsSync
API to match what we already have forvalue
andvalueSync
.The react hooks already expose a
data
field that is the rows (it was doing the conversion there), so I don't think we need to change that API.That being said, currently the
subscribe
API also returns theMap
form of the data - if we want that to return rows and phase out theMap
format entirely, it will be a significant, breaking change.