Skip to content

Docs/simple app: experience could be better #1717

Closed
@CreaturesInUnitards

Description

@CreaturesInUnitards

IMHO the simple app is an excellent introduction to mithril; however it falls down in some critical places for the uninitiated:

  1. Saves to the free heroku service don't always work, which could lead a noob to think — quite reasonably — that the framework itself is failing. Or that they've failed to duplicate the code properly. There is nothing that alerts the dev that saves aren't really happening. If the tutorial is intended to be the newcomer's first real experience with mithril, I would contend that this breakage in functionality is crippling to the framework's potential reach. The tutorial must be airtight.

  2. The code as it stands never updates the local cache. This is, in my experience, one of the great potential pitfalls for noobs.

  3. When we navigate to UserForm, we retrieve the User from the webservice, and not from our local cache. This enables the scenario of navigating directly to the UserForm without first viewing the list, but it means we're editing a separate object rather than the one which may already exist in our local cache (User.list).

  4. The entire list is retrieved every time we navigate to UserList.

I think the necessary concepts can be taught better and more reliably if changes are made to address the above issues. My top-of-head suggestions:

  1. Ditch the remote server, and instead make m.request calls to a local JSON file. This is server spoofage at its least complex and transparent, and can guarantee that a properly configured environment will function predictably. Move calls to actual web apis into a separate, more advanced tutorial.

  2. Changes made to the edited "user" must be reflected in User.list. Obviously there are myriad approaches; I'd suggest working directly against the cached object at first, and then later in the tutorial — or in another, more-advanced tutorial — copying the chosen object's fields into UserForm's vnode.state, and only applying them to the cached object upon saving.

  3. Once we introduce RouteResolvers and the Layout component, move the call to User.loadList into Layout.oninit, where: a) it will only happen once; and b) it has the added benefit of populating the local cache and ensuring that we're not working with a duplicate object.

I'll happily put together a PR if the braintrust agrees.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: DocumentationFor anything dealing mainly with the documentation itself

    Type

    No type

    Projects

    Status

    Under consideration

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions