react-native-awesome-medialib
Version:
A useful media selector module base on native component
59 lines (42 loc) • 1.74 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.UploadAvatarFailNotification = exports.OnNextStepNotification = exports.rxEventBus = exports.Event = void 0;
var _rxjs = require("rxjs");
var _operators = require("rxjs/operators");
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
class Event {
constructor(name, value) {
_defineProperty(this, "name", void 0);
_defineProperty(this, "value", void 0);
this.name = name;
this.value = value;
}
}
exports.Event = Event;
class RxEventBus {
constructor() {
_defineProperty(this, "eventSubject", void 0);
_defineProperty(this, "send", (name, value = null) => {
const event = new Event(name, value);
this.eventSubject.next(event);
});
_defineProperty(this, "sendWithValue", (key, value) => {
const event = new Event(key, value);
this.eventSubject.next(event);
});
_defineProperty(this, "listen", name => {
return this.eventSubject.pipe((0, _operators.filter)(e => e.name === name), (0, _operators.map)(e => e.value));
});
_defineProperty(this, "open", () => this.eventSubject.pipe());
this.eventSubject = new _rxjs.Subject();
}
}
const rxEventBus = new RxEventBus();
exports.rxEventBus = rxEventBus;
const OnNextStepNotification = 'OnNextStepNotification';
exports.OnNextStepNotification = OnNextStepNotification;
const UploadAvatarFailNotification = 'UploadAvatarFailNotification';
exports.UploadAvatarFailNotification = UploadAvatarFailNotification;
//# sourceMappingURL=RxEventBus.js.map