Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ApplicationCore and INavigator dependency #12

Open
FoggyFinder opened this issue Feb 2, 2018 · 0 comments
Open

ApplicationCore and INavigator dependency #12

FoggyFinder opened this issue Feb 2, 2018 · 0 comments
Labels

Comments

@FoggyFinder
Copy link
Collaborator

For now ApplicationCore and INavigator have not explicit dependency. But constructor takes function navUpdate (from INavigator) as a parameter

type ApplicationCore<'Model,'Nav,'Message> (initialModel, navUpdate : (ApplicationCore<'Model,'Nav,'Message> -> 'Nav -> unit), update, binding)

as a result, the use of navigation is not immediately obvious

let navigator = Navigation.singlePage App MainWin Login updateNavigation
let app = Program.applicationCore navigator.Navigate
Framework.RunApplication (navigator, app)

Anyway, it looks to me like implicit dependency.

But what if a bond for these types will be strong? For example

type ApplicationCore<'Model,'Nav,'Message> (initialModel, nav:INavigator<'Model, 'Nav, 'Message>, update, binding) =             

    member this.Navigation (msg : 'Nav) = 
        async {
            do! Async.SwitchToContext syncContext
            nav.Navigate this msg
        } |> Async.Start

    member __.Navigator : INavigator<'Model, 'Nav, 'Message> = nav 

and INavigator<'Model, 'Nav, 'Message> =
        abstract member Run : ApplicationCore<'Model,'Nav,'Message> -> (System.Threading.SynchronizationContext -> ObservableBindingSource<'Message>) -> unit
        abstract member Navigate : ApplicationCore<'Model,'Nav,'Message> -> 'Nav -> unit

and with a bit change of RunApplication

[<AbstractClass;Sealed>]
type Framework =
    /// Run an application given an Application generator, Window generator, and other required information
    static member RunApplication<'Model,'Nav,'Message> (applicationInfo : Framework.ApplicationCore<'Model,'Nav,'Message>) =        
        Framework.Framework.runApplication (App.toApplicationSpecification applicationInfo.Navigator applicationInfo) 

then the example above could be rewritten as

Navigation.singlePage App MainWin Login updateNavigation  
|> Program.applicationCore
|> Framework.RunApplication

which is slightly easier to perceive.

So, it's just a thought about navigation system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant