In some cases, it makes sense to postpone initialization of some module.
Such part of state can expressed using Maybe
type like
type alias Model
{ about : About.Model
, userSettings : Maybe UserSettings.Model
}
or for instance using sum type like
type Model
= About About.Model
| UserSettings UserSettings.Model
In such cases though, the programmer is responsible for manually initializing the module at the right time.
Glue.Internal.Glue model (Maybe subModel) msg subMsg
initLater : LazyGlue model subModel msg subMsg -> ( Maybe subModel -> a, Platform.Cmd.Cmd msg ) -> ( a, Platform.Cmd.Cmd msg )
Compatible with Glue.init style initialization but assigns Nothing
to the part of model that
should be initalized later. This function is useful in cases using record with maybes.
initNow : LazyGlue model subModel msg subMsg -> ( subModel, Platform.Cmd.Cmd subMsg ) -> ( Maybe subModel -> a, Platform.Cmd.Cmd msg ) -> ( a, Platform.Cmd.Cmd msg )
Similar to initLater
but for cases when
you need to initialize with Just model
right away in init function.
forceInit : LazyGlue model subModel msg subMsg -> ( subModel, Platform.Cmd.Cmd subMsg ) -> ( model, Platform.Cmd.Cmd msg ) -> ( model, Platform.Cmd.Cmd msg )
Force intialization of module. If model state already exists in the form of Just model
this value is overwrite nontherless
forceInitModel : LazyGlue model subModel msg subMsg -> subModel -> model -> model
Force intialization of module. If model state already exists in the form of Just model
this value is overwrite nontherless
ensure : LazyGlue model subModel msg subMsg -> (() -> ( subModel, Platform.Cmd.Cmd subMsg )) -> ( model, Platform.Cmd.Cmd msg ) -> ( model, Platform.Cmd.Cmd msg )
Initialize model only when state doesn't already exist (Nothing
is current value)
ensureModel : LazyGlue model subModel msg subMsg -> (() -> subModel) -> model -> model
Initialize model only when state doesn't already exist (Nothing
is current value)
update : LazyGlue model subModel msg subMsg -> (a -> subModel -> ( subModel, Platform.Cmd.Cmd subMsg )) -> a -> ( model, Platform.Cmd.Cmd msg ) -> ( model, Platform.Cmd.Cmd msg )
Like Glue.update
but for LazyGlue
variant.
Update is called only when there model is already initialized.
In cases where update should be forcing intialization use this in
conjuction with ensure
updateModel : LazyGlue model subModel msg subMsg -> (a -> subModel -> subModel) -> a -> model -> model
Like Glue.updateModel
but for LazyGlue
variant.
Update is called only when there model is already initialized.
In cases where update should be forcing intialization use this in
conjuction with ensureModel
updateWith : LazyGlue model subModel msg subMsg -> (subModel -> ( subModel, Platform.Cmd.Cmd subMsg )) -> ( model, Platform.Cmd.Cmd msg ) -> ( model, Platform.Cmd.Cmd msg )
Like Glue.updateWith
but for LazyGlue
variant.
Update is called only when there model is already initialized.
In cases where update should be forcing intialization use this in
conjuction with ensure
updateModelWith : LazyGlue model subModel msg subMsg -> (subModel -> subModel) -> model -> model
Like Glue.updateModelWith
but for LazyGlue
variant.
Update is called only when there model is already initialized.
In cases where update should be forcing intialization use this in
conjuction with ensureModel
trigger : LazyGlue model subModel msg subMsg -> (subModel -> Platform.Cmd.Cmd subMsg) -> ( model, Platform.Cmd.Cmd msg ) -> ( model, Platform.Cmd.Cmd msg )
Like Glue.triger
but for LazyGlue
variant.
Update is called only when there model is already initialized.
In cases where update should be forcing intialization use this in
conjuction with ensure
subscriptions : LazyGlue model subModel msg subMsg -> (subModel -> Platform.Sub.Sub subMsg) -> (model -> Platform.Sub.Sub msg) -> model -> Platform.Sub.Sub msg
Like Glue.subscriptions
but for LazyGlue
variant.
Update is called only when there model is already initialized.
subscriptionsWhen : (model -> Basics.Bool) -> LazyGlue model subModel msg subMsg -> (subModel -> Platform.Sub.Sub subMsg) -> (model -> Platform.Sub.Sub msg) -> model -> Platform.Sub.Sub msg
Like Glue.subscriptionsWhen
but for LazyGlue
variant.
Update is called only when there model is already initialized.
view : LazyGlue model subModel msg subMsg -> (subModel -> Html subMsg) -> model -> Maybe (Html msg)
Similar to Glue.view
but forces user to handle Nothing
case
because API of this module can't really guarantee view won't be called
with uninitialized Model.