Skip to content

Commit

Permalink
add callback
Browse files Browse the repository at this point in the history
  • Loading branch information
magicismight committed Nov 16, 2016
1 parent c03b48b commit 6a8473b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ npm-debug.log
# webstorm
#
*.iml

Examples/ios/.DS_Store
Binary file removed Examples/ios/.DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions lib/AppRegistryInjection.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ AppRegistry.registerComponent = function (appKey, getAppComponent) {
emitter.removeListener('siblings.update', this._update);
};

_update(id, element) {
_update(id, element, callback) {
if (siblings.has(id) && !element) {
siblings.delete(id);
} else {
siblings.set(id, element);
}
updates.add(id);
this.forceUpdate();
this.forceUpdate(callback);
};

render() {
Expand Down
12 changes: 6 additions & 6 deletions lib/SiblingsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ const styles = StyleSheet.create({
let uid = 0;

export default class {
constructor(element) {
constructor(element, callback) {
Object.defineProperty(this, '_id', {
enumerable: false,
configurable: false,
writable: false,
value: uid++
});

this.update(element);
this.update(element, callback);
};

_offstreamElement(element) {
Expand All @@ -29,11 +29,11 @@ export default class {

_id = null;

update(element) {
emitter.emit('siblings.update', this._id, this._offstreamElement(element));
update(element, callback) {
emitter.emit('siblings.update', this._id, this._offstreamElement(element), callback);
};

destroy() {
emitter.emit('siblings.update', this._id, null);
destroy(callback) {
emitter.emit('siblings.update', this._id, null, callback);
};
}

0 comments on commit 6a8473b

Please sign in to comment.