Skip to content

Migrate to Core #876

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

Merged
merged 8 commits into from
Jun 4, 2024
Merged

Migrate to Core #876

merged 8 commits into from
Jun 4, 2024

Conversation

aspeddro
Copy link
Collaborator

@aspeddro aspeddro commented Jun 2, 2024

No description provided.

@aspeddro aspeddro self-assigned this Jun 2, 2024
Copy link

vercel bot commented Jun 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rescript-lang.org ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 4, 2024 2:53am

Comment on lines 32 to 34
// TODO(aspeddro)
// let isDiv = Js.Null_undefined.isNullable(el["type"])
let isDiv = Nullable.toOption(el["type"])->Option.isSome
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Option.isSome is alternative to Js.Null_undefined.isNullable, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really, as it is not optimized by the compiler in the null case
I am not really sure why this did not make it into Core, @zth ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Js.Null_undefined.isNullable

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's just
external isNullable: t<'a> => bool = "#is_nullable"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, probably just a miss. Care to PR it?

Copy link
Collaborator Author

@aspeddro aspeddro Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I Opened a PR on Core. I'll leave Js.Null_undefined.isNullable until a new version of Core is released

let focusInput = () =>
input.current
->Js.Nullable.toOption
->Belt.Option.forEach(input => input->focus)
->Nullable.toOption
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is also Nullable.forEach now

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 6d659e5


let onClick = _ => {
inputEl.current
->Js.Nullable.toOption
->Belt.Option.forEach(input => input->focus)
->Nullable.toOption
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nullable.forEach

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 6d659e5

let setTextInputRef = element => {
textInput.current = element;
}

let focusTextInput = _ => {
textInput.current
->Js.Nullable.toOption
->Belt.Option.forEach(input => input->focus)
->Nullable.toOption
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nullable.forEach

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 6d659e5


let focusInput = () =>
switch textInput.current->Js.Nullable.toOption {
switch textInput.current->Nullable.toOption {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to convert to option anymore, just pattern-match directly:

switch textInput.current {
| Value(dom) => dom->focusNull | Undefined => ()
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 6d659e5

let setTextInputRef = element => {
textInput.current = element;
}

let focusTextInput = _ => {
textInput.current
->Js.Nullable.toOption
->Belt.Option.forEach(input => input->focus)
->Nullable.toOption
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nullable.forEach

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 6d659e5

src/ApiDocs.res Outdated
</div>
<div className="hl-overline text-gray-80 mt-5 mb-2"> {"submodules"->React.string} </div>
{node.children
->Js.Array2.sortInPlaceWith((v1, v2) => v1.name > v2.name ? 1 : -1)
->Js.Array2.map(renderNode)
->Belt.SortArray.stableSortBy((v1, v2) => v1.name > v2.name ? 1 : -1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array.toSorted might be sufficient here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 6d659e5

src/Packages.res Outdated
@@ -102,7 +100,7 @@ module Resource = {

fuser
->Fuse.search(pattern)
->Js.Array2.sortInPlaceWith((a, b) => a["item"].searchScore > b["item"].searchScore ? -1 : 1)
->Belt.SortArray.stableSortBy((a, b) => a["item"].searchScore > b["item"].searchScore ? -1 : 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, Array.toSorted is good enough

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 6d659e5

@aspeddro
Copy link
Collaborator Author

aspeddro commented Jun 4, 2024

engines in package.json updated and replace Nullable.toOption->Option.forEach to Nullable.forEach

@fhammerschmidt fhammerschmidt merged commit 5d27e1c into master Jun 4, 2024
3 checks passed
@zth zth deleted the adios-js-module branch June 4, 2024 05:34
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.

3 participants