-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change the lib to support reference from AMD, CMD and normal test AoP support for function properties add test cases (gulp and jasmine) update demo page add readme
- Loading branch information
Showing
11 changed files
with
164 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/demo/vendor | ||
/unit-test/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"directory": "vendor" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
define(function(require) { | ||
var obs = require("../src/observable"); | ||
console.log(obs); | ||
|
||
window.model = { | ||
"aaa": "aaa", | ||
"bbb": 12345, | ||
"arra": [1, 2, 3], | ||
"ccc": { | ||
"ddd": 123, | ||
"arra": [1, 2, 3], | ||
"eee": { | ||
"fff": "asdjhaskjhad" | ||
} | ||
}, | ||
"style": 2, | ||
func: function(a,b,c,d,e,f,g){ | ||
console.log(a,b,c,d,e,f,g); | ||
} | ||
}; | ||
|
||
var m2 = obs.observe(model, function(prop, value, oldValue) { | ||
console.log(prop + ": " + oldValue + " >> " + value); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "unit-test", | ||
"version": "0.0.0", | ||
"homepage": "https://github.com/Ariex/observable.js", | ||
"authors": [ | ||
"Ariex <[email protected]>" | ||
], | ||
"license": "MIT", | ||
"directory": "vendor", | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"vendor", | ||
"spec" | ||
], | ||
"dependencies": { | ||
"requirejs": "~2.1.17" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Document</title> | ||
<script data-main="app.js" src="vendor/requirejs/require.js"></script> | ||
</head> | ||
<body> | ||
|
||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# observable.js | ||
## Visioning | ||
This project aim for build a simple framework to monitor object property changes, which ca be a basic of a MVVM library like AngularJS or others. | ||
I have build a simple MVVM framework based on this library. | ||
|
||
## demo | ||
Demo is available in demo folder. Library is supporting AMD and CMD and normal reference, but this demo is based on requirejs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var gulp = require('gulp'); | ||
var jasmine = require('gulp-jasmine'); | ||
|
||
gulp.task('default', function() { | ||
return gulp.src([ | ||
'../lib/jasmine_examples/Player.js', | ||
'../lib/jasmine_examples/Song.js', | ||
//'spec/jasmine_examples/PlayerSpec.js', | ||
'spec/basic-test.js' | ||
]) | ||
.pipe(jasmine()); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "unit-test", | ||
"version": "1.0.0", | ||
"description": "unit test for obserbable.js", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"gulp": "^3.8.11", | ||
"gulp-jasmine": "^2.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
describe("Basic-tests", function() { | ||
obs = require('../../src/observable'); | ||
var model; | ||
|
||
beforeEach(function() { | ||
model = { | ||
"aaa": "aaa", | ||
"bbb": 12345, | ||
"arra": [1, 2, 3], | ||
"ccc": { | ||
"ddd": 123, | ||
"arra": [1, 2, 3], | ||
"eee": { | ||
"fff": "asdjhaskjhad" | ||
} | ||
}, | ||
"style": 2 | ||
}; | ||
}); | ||
it("Notify when string property updated", function() { | ||
var m2 = obs.observe(model, function(prop, value, oldValue){ | ||
expect(prop === "aaa").toBe(true); | ||
}); | ||
model.aaa="abcdefg"; | ||
}); | ||
it("Notify when number property updated", function() { | ||
var m2 = obs.observe(model, function(prop, value, oldValue){ | ||
expect(prop === "bbb" && model.bbb===321).toBe(true); | ||
}); | ||
model.bbb=321; | ||
}); | ||
it("Test deep property change", function() { | ||
var m2 = obs.observe(model, function(prop, value, oldValue){ | ||
expect(prop === "ccc.eee.fff").toBe(true); | ||
}); | ||
model.ccc.eee.fff=321; | ||
}); | ||
it("Notify when array property updated", function() { | ||
var m2 = obs.observe(model, function(prop, value, oldValue){ | ||
expect(model.ccc.arra.length == 4 && model.ccc.arra[3] === 321).toBe(true); | ||
}); | ||
model.ccc.arra.push(321); | ||
}); | ||
}); |