glendix/binding
Provides binding operations for Glendix.
import gleam/result
import glendix/binding
import redraw
import redraw/dom/attribute
pub fn pie_chart(
attrs attrs: List(attribute.Attribute),
children children: List(redraw.Element),
) -> Result(redraw.Element, binding.BindingError) {
use module <- result.try(binding.module("recharts"))
use component <- result.try(binding.resolve(module, "PieChart"))
Ok(binding.element(component, attrs, children))
}
Types
Describes a missing JavaScript binding.
pub type BindingError {
ModuleWasNotFound(name: String, reason: String)
ExportWasNotFound(name: String, reason: String)
}
Constructors
-
ModuleWasNotFound(name: String, reason: String)The requested JavaScript module is not registered.
-
ExportWasNotFound(name: String, reason: String)The requested export is not available from the module.
Represents one JavaScript component exported by a configured module.
pub type JsComponent
Values
pub fn element(
component component: JsComponent,
attributes attributes: List(attribute.Attribute),
children children: List(redraw.Element),
) -> redraw.Element
Creates an element from an external component, attributes, and children.
pub fn element_(
component component: JsComponent,
children children: List(redraw.Element),
) -> redraw.Element
Creates an element from an external component and children.
pub fn module(
name name: String,
) -> Result(JsModule, BindingError)
Returns a JavaScript module handle by name.
pub fn resolve(
module module: JsModule,
name name: String,
) -> Result(JsComponent, BindingError)
Resolves an exported JavaScript value from a module handle.
pub fn void_element(
component component: JsComponent,
attributes attributes: List(attribute.Attribute),
) -> redraw.Element
Creates an element from an external component without children.