Skip to content

Commit

Permalink
start of ort
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim de Beer committed Jul 25, 2016
1 parent b856eaf commit dc0166e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 19 deletions.
14 changes: 12 additions & 2 deletions lib/subscribe/any/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ module.exports = function sort (target, subs, update, tree, stamp) {
console.log('lulllz')
if (target && target.val !== null) {
let $ = target.sid()
if (!subs[subs.$sort]) {
subs[subs.$sort] = { val: true }
}
if (!('$any' in tree)) {
tree.$any = {
_p: tree,
Expand All @@ -21,8 +24,15 @@ module.exports = function sort (target, subs, update, tree, stamp) {
console.log(keys)
if (keys && keys.length) {
for (let i = 0, len = keys.length; i < len; i++) {
console.log('what do you do', keys[i], i)
if (struct(i, target[keys[i]], subs, update, tree.$any, stamp)) {
console.log('what do you do', keys[i], i, subs)
// module.exports = function struct (key, target, subs, update, tree, treeKey, stamp)
// needto jsut subs on the sort field as well
// if (!tree.$any[i]) {
// tree.$any[i] = {}
// }

if (struct(i, target[keys[i]], subs, update, tree.$any, tree.$any[i], stamp)) {
console.log('fire fire')
changed = true
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/any/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'use strict'
require('./basic')
// require('./basic')
require('./sort')
24 changes: 16 additions & 8 deletions test/any/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,29 @@ test('any - sort', function (t) {
$any: {
val: true
}
}
},
true
)

console.log(s)
const result = s('initial subscription', [ { path: 'a', type: 'new' } ])
const result = s('initial subscription', [
{ path: 'b', type: 'new' },
{ path: 'b/nr', type: 'new' },
{ path: 'a', type: 'new' },
{ path: 'a/nr', type: 'new' }
])

console.log('>', result.tree, result.state.keys())
// console.log('>', result.tree, result.state.keys())
result.state.set({
c: { nr: 2 }
}, false)

console.log(result.state.sort)
c: { nr: -10 }
})

console.log(' \n')
result.state.a.nr.set(-100)
console.log(result.state.keys())
// console.log(result.state.sort)
// s('change order', [ { path: 'b', type: 'new' }, { path: 'a', type: 'update' } ], { b: { nr: 1 } })
console.log('?', result.state._keys, result.state.keys())
// console.log('?', result.state._keys, result.state.keys())
// delete result.state._keys
// console.log('?', result.state.keys()._)

Expand Down
16 changes: 8 additions & 8 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict'
require('./init')
require('./basic')
require('./references')
require('./parent')
require('./test')
require('./set')
require('./switch')
require('./root')
// require('./init')
// require('./basic')
// require('./references')
// require('./parent')
// require('./test')
// require('./set')
// require('./switch')
// require('./root')
require('./any')

0 comments on commit dc0166e

Please sign in to comment.