0.4.25 • Published 8 years ago

nexus-node v0.4.25

Weekly downloads
111
License
-
Repository
github
Last release
8 years ago

##nexus Code Climate

An MVVM-based client application framework

Installation

Bower

$ bower i nexus

Node.js

$ npm i nexus-node

Example

# Temperature is “measured” and displayed in two scales

# Raw business domain model
class TemperatureModel
	constructor: ->
		# nx.Cell is a “spreadsheet cell”
		@celsius = new nx.Cell value:-20

# ViewModel describes data transformation for representation in views
class TemperatureViewModel extends TemperatureModel
	constructor: ->
		super
		@fahrenheit = new nx.Cell
		# Cell-oriented data flow
		@fahrenheit['<-'] @celsius, (celsius) -> celsius * 1.8 + 32

# Views are plain functions nested arbitrarily and written pseudo-declaratively
AppView = (context) ->
	nxt.Element 'main',
		nxt.Element 'div',
			# Pin-point rendering will only change this part when 
			# bound data is modified
			nxt.Binding context.celsius, (celsius) ->
				nxt.Text "#{celsius}℃"
		nxt.Element 'div',
			nxt.Binding context.fahrenheit, (fahrenheit) ->
				nxt.Text "#{fahrenheit}°F"
		nxt.Element 'button',
			nxt.Text 'Measure!'
			# fake measurement
			nxt.Event 'click', context.celsius, -> Math.round(Math.random()*50 - 25)

window.addEventListener 'load', ->
	window.model = new TemperatureViewModel
	# Attach the view to the DOM (can be any existing node)
	document.body.appendChild AppView(model).data.node
0.4.25

8 years ago

0.4.24

8 years ago

0.4.23

8 years ago

0.4.22

8 years ago

0.4.21

8 years ago

0.4.20

8 years ago

0.4.19

8 years ago

0.4.18

9 years ago

0.4.17

9 years ago

0.4.16

9 years ago

0.4.15

9 years ago

0.4.14

9 years ago

0.4.13

9 years ago

0.4.12

9 years ago

0.4.11

9 years ago

0.4.10

9 years ago

0.4.9

9 years ago

0.4.8

9 years ago

0.4.7

9 years ago

0.4.6

9 years ago

0.4.5

9 years ago

0.4.4

9 years ago

0.4.3

9 years ago

0.4.2

9 years ago

0.4.0

9 years ago

0.4.0-alpha.4

9 years ago

0.4.0-alpha.3

9 years ago