LassoJS and Marko-WIdgets

So guys, I’m in a bit little nightmare here. Starting using makoJs and Marko-widgets loving so far. But…

This is the thing I follow the organization of some samples and integrate with the lassoJS. So in the lasso way of doing things I do not get to implement the define component methods.

So what I need to accomplish:

module.exports = require('marko-widgets').defineComponent({
    template: require('./template.marko'),

    getInitialState: function(input) {
        return {
            name: input.name,
            selected: input.selected || false;
        }
    },

    getTemplateData: function(state, input) {
        var style = ;

        return {
            name: state.name,
            color: state.selected ? 'yellow' : 'transparent'
        };
    },

    handleClick: function() {
        this.setState('selected', true);
    },

    isSelected: function() {
        return this.state.selected;
    }
});

My Marko file is being writing as this:

import './style.css'

static function getClassNameForValue(value) {
    if (value < 0) {
        return 'negative';
    } else if (value > 0) {
        return 'positive';
    }
}

class {
    onInput(input) {
        var value = input.value || 0;

        this.state = {
            value: value
        };
    }

    handleIncrementClick(delta) {

        this.state.value += delta;
        var value = this.state.value;


        var send = {
            value:value
        }
        console.log(value);
        $.post( "/tryPost", send,function( data ) {
            console.log(data);
        }); 
    }

    handleInputKeyUp(event, el) {
        var newValue = el.value;
        if (/^-?[0-9]+$/.test(newValue)) {
            this.state.value = parseInt(newValue, 10);
        }
    }
}

$ var value=state.value;

Edit:
So I was thinking, know what version of those modules I’m using could help.

“lasso”: “^2.11.3”,
“lasso-less”: “^2.4.3”,
“lasso-marko”: “^2.2.2”,
“lodash”: “^4.17.4”,
“markdown-js”: “0.0.3”,
“marked”: “^0.3.6”,
“marko”: “^4.0.0-rc.18”,
“marko-widgets”: “^6.6.0”

So how, to implement the listener for events of the lifecycle?


Source: stackoverflow-javascript