var edge = require('edge'); // http://tjanczuk.github.io/edge | |
var Rx = require('rxjs'); // https://github.com/Reactive-Extensions/RxJS | |
var createSubject = edge.func({ | |
// this is c# | |
source: function () {/* | |
using System.Reactive.Linq; | |
using System.Reactive.Subjects; | |
using ClassLibrary1; | |
async (dynamic input) => { | |
return new Class1().Make(" a new thng"); | |
} | |
*/}, | |
references: [ | |
//__dirname + '\\System.Reactive.Core.dll', | |
//__dirname + '\\System.Reactive.Linq.dll', | |
__dirname + '\\ClassLibrary1.dll', | |
__dirname + '\\System.Reactive.Interfaces.dll', | |
'System.Runtime.dll', | |
'System.Threading.Tasks.dll', | |
'System.Reactive.Core.dll', | |
'System.Reactive.Linq.dll', | |
] | |
}); | |
var MySubject = (function () { | |
return function () { | |
var subject = createSubject({ what: 'happens'}, true); | |
var observable = Rx.Observable.create(function (obs) { | |
subject.subscribe(function (data, cb) { | |
process.nextTick(function () { | |
obs.next(data); | |
}); | |
cb(); | |
}); | |
return function() { | |
console.log('disposed!'); | |
} | |
}); | |
var observer = { | |
next(x) { | |
subject.onNext(x, true); | |
}, | |
}; | |
//return observable.do(x => console.log({ x })); | |
return Rx.Subject.create(observer, observable); | |
} | |
}()); | |
const s = MySubject(); | |
s.subscribe(function (data) { | |
console.log('Got data: ' + data); | |
}); | |
Rx.Observable.timer(0, 500) | |
.take(10) | |
.subscribe(function (x) { | |
s.next(x); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment