-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
notes on the future namespace-based API #2759
Comments
Just an idea. Why do not have all functions in 'slate' with namespaces in their names? import { createMark, getNode, getNodeAncestors, isPointAfter } from 'slate'; People using TypeScript just write 'isPointAfter' and VSCode will import automatically. |
@steida that’s a great question. And I think it’s still an option. I lean towards the separate namespaces right now because I think it makes it a bit more clear as to what interface they accept. The first argument will always be one of the objects themselves. |
It can be both. Separate namespaces and full names. Node etc. can be re-exported from slate. And we can just write "a bit more clear as to what interface they accept" That's a task for VSCode. It shows types even in plain JavaScript. Anyway, it's up to you. I am only thinking aloud. Thank you for your precious work. Also: https://twitter.com/GiulioCanti/status/1127249761134948352 |
@steida that's a good point, we could consider exporting both and just seeing which one is most useful over time if only one ends up being used. |
Fixed by #3093. |
In light of #2495 and switching to using an interface-based API with plain JavaScript objects and arrays, the core API will change. Using plain JavaScript data means that we can eliminate a decent amount of code I think, and it means we'll move to mimicking native namespaced utils like
Object.entries(object)
.This issue is just note to keep track of the "ideal" future interface-and-namespace-based API, as I think of improvements. We'll work towards it over a series of versions, since we want to keep things incremental and deprecation-friendly whenever possible.
But here's a sketch...
// TODO: the other interfaces...
It's funny, I thought it was going to make things more verbose, but in reality the before and after is pretty similar (and in some cases more clear) for many of them:
And the iterators are similar to how
Object.entries()
works:Overall pretty excited for how it's shaking out. If you want to help make this happen, anything to further #2495 is the best way to do that! Thanks.
The text was updated successfully, but these errors were encountered: