fable-compiler / fable-arch

Framework for building applications based on the elm architecture.
https://fable-compiler.github.io/fable-arch/
Apache License 2.0
60 stars 14 forks source link

Add sample for complex sub applications #35

Closed MangelMaxime closed 7 years ago

MangelMaxime commented 8 years ago

Today Dave Thomas was asking about:

Is there an equivalent to App.map in fable-arch? http://package.elm-lang.org/packages/elm-lang/html/1.0.0/Html-App#map

Here was my answer but it's not really refined we need to make a real sample of it.

/// Actions from my Main app
type Actions
    = ShowIndex
    | ShowSignIn
    | ShowDashboard
    | SignInActions of SignIn.Actions // Here is a an actions to map sub applications actions

/// Update sample
let update model action =
    let model', action' =
      match action with
      | ShowIndex | ShowSignIn ->
        Model.Generate (Some SignIn, model.UserSession, signIn = SignIn.Model.Initial), []
      | _ ->
        // Here we are mapping the sub app actions to the main Application
        let (res, action) = SignIn.update model.SignIn.Value act
        let action' = mapActions SignInActions action
        { model with SignIn = Some res}, action'
      | _ ->
        model, []

    model', action'

/// Here is a sample for the View
let view model =
    let html', hasMenu =
      match model.CurrentRoute with
      | Some r ->
        match r with
        | Index | SignIn ->
          Html.map SignInActions (SignIn.view model.SignIn.Value), true
        | _ ->
          div [] [ text "404" ], false
      | None ->
        div [] [ text "404" ], false

@mastoj I am more and more thinking about making a mini website demonstration with all the possible case usage for a classic web site.

So here are the specs:

I can make the job to create the sample :). Do you see any others specs to add ?

Another questions is does the documentation generation support multiple files projects ? Because for this samples, I will need to write several files otherwise it's would not readable.

And finally, should we go for .fsx files or .fsproj ? :)

mastoj commented 8 years ago

If you have the time to put together a complete example that would be highly appreciated.

I like fsx, but I see the point of fsproj if it gets to complicated.

MangelMaxime commented 8 years ago

So I will go with the fsproj as it's will be easier to extends in the future :)

mastoj commented 8 years ago

The problem is that the build /publish scripts aren't updated for fsproj, but it might work out of the box :).

On Wed, Sep 21, 2016, 13:39 Maxime Mangel notifications@github.com wrote:

So I will go with the fsproj as it's will be easier to extends in the future :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fable-compiler/fable-arch/issues/35#issuecomment-248586253, or mute the thread https://github.com/notifications/unsubscribe-auth/AAemsPRqCjhF4kvLYXW2-ghm6zVttxCBks5qsRdYgaJpZM4KCsNk .

mastoj commented 8 years ago

Go with fsproj anyway, it would be nice to have a sample showing how that works as well.

tforkmann commented 8 years ago

Hey there,

my solution is a bit different:

SQLProvider to access the data Suave for Routing and handling static html file Subpages on the backend -> bring sqldata to json

Fable.Arch with Ajax -> call the data from the backend Fable to compile to js Implement js to static html file

I was planning to implement that to my MinimalSuaveFable project.

I'm using fsproj files.

Do you think that could be useful?

tforkmann commented 8 years ago

Hey there,

my solution is a bit different:

SQLProvider to access the data Suave for Routing and handling static html file Subpages on the backend -> bring sqldata to json

Fable.Arch with Ajax -> call the data from the backend Fable to compile to js Implement js to static html file

I was planning to implement that to my MinimalSuaveFable project.

I'm using fsproj files.

Do you think that could be useful?

MangelMaxime commented 8 years ago

Not sure to follow you @tforkmann

What you are speaking about here is not only about Fable.Arch but a full Server stack (back and front end).

Here for the routing we will demonstrate on Fable.Arch this will be for SPA application. So we will just show how to use Fable.Arch as an independent client and show the different case possible (show how to use ajax, nested application, routing, etc.)

Then the user can choose how he want to use Fable.Arch as there not only one way to things. You can go for SPA. You can go for Server side routing like you seems to do, etc.

tforkmann commented 8 years ago

OK,

thanks for your answer. Sorry for taking the decision of course.

MangelMaxime commented 8 years ago

No but there nothing wrong. :)

Your sample is good :). Here we just want to make a tutorial about Fable.Arc. If Thomas is Ok with me.

But you can make an update to MinimalSuaveFable or propose a full stack sample of course :). It's just we start to show a sample using backend etc. We will have to maintain the back and also we can't make it static to demonstration the sample on docs.

mastoj commented 8 years ago

I wouldn't mind having a sample project with a suave backend as well. But as you both concluded, it is a different sample.

mastoj commented 8 years ago

And as @mangelmaxime pointed out, it wouldn't be a sample in the same way as the other projects. But we could definitely add it somewhere and write some docs around it.

tforkmann commented 8 years ago

I will update my sample and will start writing some docs for it.

MangelMaxime commented 8 years ago

I am going back to write the sample. Just waiting to find a fix for Aether because it have a bug again in the generated JS.

MangelMaxime commented 7 years ago

I will close this issue because the docs site is now a complexe application demo.