DEV Community

Discussion on: Imba - a JavaScript alternative for increased developer productivity

Collapse
 
konung profile image
konung

Thank you Sindre for a thorough answer, I will certainly try out Imba :)

Thread Thread
 
konung profile image
konung

@somebee Could you mention, what current features are lacking/WIP? Or maybe there is a Roadmap?
Just trying to guage what limitations are.

i.e. with Elm the limitation (for my projects) turned out to be the delibirate slow release schedule. Creator of the language addressed it many times and gave his (valid) reasons for doing so. But if I knew about that beforehand, I might have not chosen Elm for a project, despite ti's no-runtime-errors guarantee.

Thread Thread
 
somebee profile image
Sindre Aarsaether

I will try to put up an official roadmap soon. There are definitely features lacking, but I wouldn't hesitate using it in production. There are things I plan to add, like custom SVG components, but nothing major missing for v2.

Our problem is rather too frequent releases. The main reason we haven't officially moved to beta is that it feels easier to release very frequent updates while in alpha.

Thread Thread
 
konung profile image
konung

:) That's a good problem to have :)

Thread Thread
 
konung profile image
konung • Edited

@somebee I started going through docs on imba.io website ❤️, and one thing that I found missing/WIP ( for my use cases) is global state-managment Redux-like.

I understand it's possible, but can't find a doc or an exmple or a video-tutorial of one. I noticed you recorded a lot of meetups - is there one per-chance where you discuss & show it?

Thread Thread
 
codeluggage profile image
Matias

Documentation on state is right around the corner and is being discussed in the Discord community right now, but here's a quick answer:

How do I manage global state? / Where do I use Vuex/Redux/Mobx?

The answer is mind boggling because of how simple it is; you don't. It kind of feels like something is missing, coming from the big web frameworks where thinking about state is a huge part of the day to day work.

When working with the web directly, instead of through the virtual DOM layer of abstraction, it can be as simple as this:

1) Make a new file for state to live in - for example state.imba
2) Export a regular Javascript object to use as the default state - for example:

export let state = {
    answer: 42,
    question: "The Ultimate Question of Life, the Universe, and Everything"
}
Enter fullscreen mode Exit fullscreen mode

That covers the concept of global state, MUTATIONS and GETTERS. For the concept of ACTIONS we can add this, for example:

export def increment
    state.answer++

export def decrement
    state.answer--
Enter fullscreen mode Exit fullscreen mode

3) Use it wherever you need. Here's a full app that imports the state above and uses it for an important calculation:

import {
    state
    increment
    decrement
} from './state'

tag app
    <self>
        <h2>
            if state.answer !== 42
                "A number"
            else
                state.question
        <button @click=decrement> "-"
        <pre> state.answer
        <button @click=increment> "+"

imba.mount <app>
Enter fullscreen mode Exit fullscreen mode

Here's a little repo of the above example: github.com/codeluggage/imba-basic-...

Thread Thread
 
konung profile image
konung

Wow . This is awesome !

One more question:
Can you bind to state ? If state changes from one component can you force an automatic update in another component connected/dependent on the same state variable ?