mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
node: ComponentDefinition::create returns now a result instead of an optional (#4622)
This commit is contained in:
parent
f23c768204
commit
f03aedf14c
1 changed files with 3 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
|||
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
|
||||
|
||||
use napi::Result;
|
||||
use slint_interpreter::ComponentDefinition;
|
||||
|
||||
use super::{JsComponentInstance, JsProperty};
|
||||
|
@ -57,12 +58,8 @@ impl JsComponentDefinition {
|
|||
}
|
||||
|
||||
#[napi]
|
||||
pub fn create(&self) -> Option<JsComponentInstance> {
|
||||
if let Ok(instance) = self.internal.create() {
|
||||
return Some(instance.into());
|
||||
}
|
||||
|
||||
None
|
||||
pub fn create(&self) -> Result<JsComponentInstance> {
|
||||
Ok(self.internal.create().map_err(|e| napi::Error::from_reason(e.to_string()))?.into())
|
||||
}
|
||||
|
||||
#[napi(getter)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue