You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In debug mode init is called twice - from src/Debug/Navigation.ts:
function createProgram<Model, Msg, Dom>(
stopDebuggerOn: Observable<unknown>,
locationToMessage: (location: Location) => Msg,
init: (location: Location) => [Model, Cmd<Msg>],
update: (msg: Msg, model: Model) => [Model, Cmd<Msg>],
view: (model: Model) => Html<Dom, Msg>,
subscriptions?: (model: Model) => Sub<Msg>
): Program<Model, Msg, Dom> {
const history = H.createHashHistory() // this is needed only to generate init model for debug$ :S
const Debugger = runDebugger<Model, Msg>(window, stopDebuggerOn)
const initModel = init(history.location)[0] // init called first time
const debug$ = new BehaviorSubject<DebugData<Model, Msg>>([debugInit(), initModel])
const p = program(locationToMessage, init, updateWithDebug(debug$, update), view, subscriptions) //init will be called second time
// --- Run the debugger
// --- we need to make a type assertion for `dispatch` because we cannot change the intrinsic `msg` type of `program`;
// --- otherwise `programWithDebugger` won't be usable as a transparent extension/substitution of `Html`'s programs
Debugger({
debug$,
init: initModel,
dispatch: p.dispatch as DebuggerR<Model, Msg>['dispatch']
})()
return p
}
Dirty workaround is to keep init counter inside file, but I think calling init twice is a bug
The text was updated successfully, but these errors were encountered:
@padzikm we need to call init the first time in order to get the initial program's Model to:
create the debug$ stream
pass the initial state to the redux-dev-tool extension (in case it is installed - but the Debugger interface is intentionally agnostic/more general so we can add other types of debugger in the future)
Which is your problem (related to a double call to init)? In theory init should not execute any side-effect, it only defines the initial Model and Cmd so it should be safe executing it twice
In debug mode init is called twice - from src/Debug/Navigation.ts:
Dirty workaround is to keep init counter inside file, but I think calling init twice is a bug
The text was updated successfully, but these errors were encountered: