So ignore has the following signature: 'a => unit, it will only work for functions that have one arbitrary parameter and return unit. In your case, updateSW has the signature unit => unit which can be unified by the type checker without errors.
If you had a more complex function like
@val external registerSW: opts => (string, int) => unit = "registerSW"
You would probably initialize it wrapped in an option:
let updateSWRef = ref(None)
updateSWRef :=
Some(
registerSW({
foo: <button
onClick={_ => {
updateSWRef.contents->Option.forEach(updateSWRef =>
updateSWRef("abc", 123)
)
}}
/>,
}),
)
And the ignore function is equivalent to this:
let ignore = _param1 => ()
So you could also create your own ignore functions if the signature of the built-in one does not match.
let ignore2 = (_param1, _param2) => ()
Caveat: The compiler won’t optimize them away like the built-in one.
Does that clarify it?