Header menu logo Mibo

Sub Module

Functions for creating and composing Elmish subscriptions.

Subscriptions connect external event sources to the Elmish update loop. The runtime automatically manages subscription lifecycle based on SubId diffing.

Functions and values

Function or value Description

batch subs

Full Usage: batch subs

Parameters:
    subs : Sub<'Msg> seq

Returns: Sub<'Msg>

Combines multiple subscriptions into a single subscription.

Subscriptions are merged efficiently and duplicates are not filtered. Use unique SubIds to ensure proper subscription diffing.

subs : Sub<'Msg> seq
Returns: Sub<'Msg>

batch2 (a, b)

Full Usage: batch2 (a, b)

Parameters:
Returns: Sub<'Msg>
Modifiers: inline
Type parameters: 'Msg

Combines exactly 2 subscriptions with minimal allocation overhead.

a : Sub<'Msg>
b : Sub<'Msg>
Returns: Sub<'Msg>

batch3 (a, b, c)

Full Usage: batch3 (a, b, c)

Parameters:
Returns: Sub<'Msg>
Modifiers: inline
Type parameters: 'Msg

Combines exactly 3 subscriptions with minimal allocation overhead.

a : Sub<'Msg>
b : Sub<'Msg>
c : Sub<'Msg>
Returns: Sub<'Msg>

batch4 (a, b, c, d)

Full Usage: batch4 (a, b, c, d)

Parameters:
Returns: Sub<'Msg>
Modifiers: inline
Type parameters: 'Msg

Combines exactly 4 subscriptions with minimal allocation overhead.

a : Sub<'Msg>
b : Sub<'Msg>
c : Sub<'Msg>
d : Sub<'Msg>
Returns: Sub<'Msg>

map idPrefix f sub

Full Usage: map idPrefix f sub

Parameters:
    idPrefix : string
    f : 'A -> 'Msg
    sub : Sub<'A>

Returns: Sub<'Msg>

Maps a subscription producing messages of type 'A to produce messages of type 'Msg.

This is essential for parent-child composition where child modules have their own message types. The idPrefix is prepended to all subscription IDs to namespace them properly.

idPrefix : string
f : 'A -> 'Msg
sub : Sub<'A>
Returns: Sub<'Msg>
Example

 // In parent module:
 let childSub = Child.subscribe ctx |> Sub.map "child" ChildMsg
val childSub: obj

none

Full Usage: none

Returns: Sub<'a>

An empty subscription that does nothing. Use when no subscriptions are needed.

Returns: Sub<'a>

Type something to start searching.