mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-01-22 16:49:22 -05:00
Docs: Update vibration pattern documentation and convert helper function
- Updated comment for `vibrate` to describe the `Vec<u16>` format for vibration patterns. - Modified `vibration_pattern_to_jsvalue` to accept a slice (`&[u16]`) and convert it to a `JsValue` array.
This commit is contained in:
parent
81f09cb278
commit
54a04ac382
1 changed files with 6 additions and 4 deletions
|
@ -281,7 +281,8 @@ pub struct UseWebNotificationOptions {
|
|||
#[builder(into)]
|
||||
silent: Option<bool>,
|
||||
|
||||
/// A `Vec<u16>` value specifying the vibration pattern in which the device is vibrating and not vibrating.
|
||||
/// A `Vec<u16>` specifying the vibration pattern in milliseconds for vibrating and not vibrating.
|
||||
/// The last entry can be a vibration since it stops automatically after each period.
|
||||
#[builder(into)]
|
||||
vibrate: Option<Vec<u16>>,
|
||||
|
||||
|
@ -416,7 +417,8 @@ pub struct ShowOptions {
|
|||
#[builder(into)]
|
||||
silent: Option<bool>,
|
||||
|
||||
/// A `Vec<u16>` value specifying the vibration pattern in which the device is vibrating and not vibrating.
|
||||
/// A `Vec<u16>` specifying the vibration pattern in milliseconds for vibrating and not vibrating.
|
||||
/// The last entry can be a vibration since it stops automatically after each period.
|
||||
#[builder(into)]
|
||||
vibrate: Option<Vec<u16>>,
|
||||
}
|
||||
|
@ -477,8 +479,8 @@ fn browser_supports_notifications() -> bool {
|
|||
false
|
||||
}
|
||||
|
||||
/// Helper function to convert `Vec<u16>` into a `JsValue` array that represents a vibration pattern
|
||||
fn vibration_pattern_to_jsvalue(pattern: &Vec<u16>) -> JsValue {
|
||||
/// Helper function to convert a slice of `u16` into a `JsValue` array that represents a vibration pattern
|
||||
fn vibration_pattern_to_jsvalue(pattern: &[u16]) -> JsValue {
|
||||
let array = js_sys::Array::new();
|
||||
for &value in pattern.iter() {
|
||||
array.push(&JsValue::from(value));
|
||||
|
|
Loading…
Add table
Reference in a new issue