-
-
Notifications
You must be signed in to change notification settings - Fork 250
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
Migrate to Core #876
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
src/components/SearchBox.res
Outdated
// TODO(aspeddro) | ||
// let isDiv = Js.Null_undefined.isNullable(el["type"]) | ||
let isDiv = Nullable.toOption(el["type"])->Option.isSome |
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.
I think Option.isSome
is alternative to Js.Null_undefined.isNullable
, right?
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.
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 ?
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.
Which one?
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.
Js.Null_undefined.isNullable
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.
it's just
external isNullable: t<'a> => bool = "#is_nullable"
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.
Ah, probably just a miss. Care to PR it?
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.
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 |
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.
there is also Nullable.forEach
now
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.
Done 6d659e5
|
||
let onClick = _ => { | ||
inputEl.current | ||
->Js.Nullable.toOption | ||
->Belt.Option.forEach(input => input->focus) | ||
->Nullable.toOption |
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.
Nullable.forEach
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.
Done 6d659e5
let setTextInputRef = element => { | ||
textInput.current = element; | ||
} | ||
|
||
let focusTextInput = _ => { | ||
textInput.current | ||
->Js.Nullable.toOption | ||
->Belt.Option.forEach(input => input->focus) | ||
->Nullable.toOption |
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.
Nullable.forEach
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.
Done 6d659e5
|
||
let focusInput = () => | ||
switch textInput.current->Js.Nullable.toOption { | ||
switch textInput.current->Nullable.toOption { |
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.
no need to convert to option anymore, just pattern-match directly:
switch textInput.current {
| Value(dom) => dom->focus
| Null | Undefined => ()
}
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.
Done 6d659e5
let setTextInputRef = element => { | ||
textInput.current = element; | ||
} | ||
|
||
let focusTextInput = _ => { | ||
textInput.current | ||
->Js.Nullable.toOption | ||
->Belt.Option.forEach(input => input->focus) | ||
->Nullable.toOption |
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.
Nullable.forEach
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.
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) |
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.
Array.toSorted might be sufficient here?
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.
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) |
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.
again, Array.toSorted is good enough
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.
Done 6d659e5
|
No description provided.