GithubHelp home page GithubHelp logo

aneteanetes / geranium Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 18.79 MB

MVVM frontend framework

TypeScript 100.00%
es6-javascript frontend-framework ioc-container ioc-framework mvvm-architecture mvvm-framework typescript

geranium's People

Contributors

aneteanetes avatar

Stargazers

 avatar

Watchers

 avatar  avatar

geranium's Issues

State-singleton worked not as expected

Code example

class ServerStateProvider extends State {
	get synchronizer() {
		if (this.current.length == 0)
			return {
				url: 'get state from .server',
				method: 'post'
			};
		else
			return undefined;
	}

	current: string = "";
}

@Routeroot
class StateViewer extends ViewState {
	view() { return '<h1 data-field="current">{{current}}</h1>'; }
	current: string = "";

	async show(selector: string) {
		if (!this.current) {
			var serverState = await State.get(ServerStateProvider);
			this.obtain(serverState);
		}
		super.show(selector);
	}
}

class Controls extends ViewModel {
	view() { return '<button onclick="showState">show</button>'; }

	async showState() {
		var stateViewer = await State.get(StateViewer);
		stateViewer.show('.app');
	}
}

$(document).ready(x => new Controls().display('.controls'));

Compiled result

<button>show</button>
<h1>its random state from server</h1>

after first button click:

<button>show</button>
<h1>server random state</h1>

after second button click:

<button>show</button>
<h1>server random state</h1>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.