Ewwii v0.5.0: Overview & Migration guide


Ewwii v0.5.0 is a yet another major overhaul of the core engine. This update simplifies the overall rendering engine by completely getting rid of reevaluation system. This brings a lot of performance to the table but at the cost of breaking compatibility with configuration written in previous releases.

Why was this change necessary?

Well, if you were to have a big configuration with a lot of updating widgets, then you will experience some latency before the widget updates. This is because the configuration is being reevaluated to generate the new AST.

And simplifying the configuration system will greatly help out the upcoming 0.6.0 release (which will be kept a secret for now).

Major Changes

The major changes in this release include:

  • Removal of localsignal and localbind
  • Removing on the fly mutability/comparability of poll, listen globals.
  • Changing how update command works.
  • Making poll, listen globals globall accessable throughout the codebase.

Migration Guide

Although there are only a few breaking changes, migration can be quite hard if you don’t know what you are doing. This is why this article exists, of course.

Using Global Variables

This release also changed how you use global variables. And don’t worry! Its more intuitive now.

Previously, you had to do something like this:

// How it used to be done
fn render(time) {
    label(#{ text: time })
}

tree([
    poll("time", #{ cmd: "date '+%H:%M'", interval: "60s" }),
    defwindow("example", #{}, render(time))
])

But now you can just do this:

// How to do it now:
fn render() {
    label(#{ text: time })
}

tree([
    poll("time", #{ cmd: "date '+%H:%M'", interval: "60s" }),
    defwindow("example", #{}, render())
])

No need to pass global variables around now. They are global! Just use it where ever you want!!

Mutating & Comparing Global Variables

This is a little complex. So bare with me here. Its a downside of the simplification.

Previously, we could just do this to mutate or compare global variables:

// Say `time` is a global variable

// comparing time
if time == "00:00" {
    print("Its midnight!")
}

// Mutates time to "Its {time}"
time = "Its " + time
print(time);

But now, global variables cannot just give out the value it contains at that moment because to do that, reevaluation is needed. So as an alternative, we use the bound function.

Here is how we mutate/compare now using bound:

// Say `time` is a global variable

// comparing global variables
let local_var = "00:00";
bound([time, local_var], |vars| {
    // `vars` is an array containing values 
    // of the global variables and local variables
    // that we passed in.
    let time = vars[0];
    let local_var = vars[1];

    if time == local_var {
        print("Its midnight")
    }

    // You can also compare like this:
    if time == "00::00" {
        print("Its midnight (2)")
    }
});


// Mutating variables / interacting with it
let mutated_value = bound([time], vars {
    let time = vars[0];

    return "Its " + time
});
// `mutated_value` can now be passed to a 
// property directly. Like so:
// label(#{ text: mutated_value })

So basically, you can still interact or mutate global variables. But it has to be done within bound.

Localsignals

Localsignal was meant to be a lightweight, local variants to poll and listen. But now that global variables are just as lightweight and easier to manage, localsignals are now obsolete.

You should use poll/listen global variables directly instead of localsignals now.

Calling Update Command

Previosly, update command’s main purpose was reloading the widgets and optionally injecting variables to rhai source code. But from now on, they have a singular purpose. That being to update values global variables.

How it was used previosuly:

ewwii update --inject "VAR1=bar,VAR2=foo2"

How it is used now:

ewwii update VAR1="bar" VAR2="foo2"

Conclusion

Despite breaking many of the previous architectural decisions and configuration, this release will be the foundation for the upcoming 0.6.0 release, which will be one of the biggest and most useful ewwii releases.