react-native-root-siblings
Advanced tools
Comparing version 3.1.7 to 3.2.0
32
index.js
@@ -43,2 +43,3 @@ import React, { Component } from 'react'; | ||
const triggers = []; | ||
const pendingSiblings = {}; | ||
class RootSiblings extends Component { | ||
@@ -49,6 +50,11 @@ _updatedSiblings = {}; | ||
constructor(props) { | ||
super(props); | ||
this._siblings = {}; | ||
componentDidMount() { | ||
triggers.push(this._update); | ||
Object.keys(pendingSiblings).forEach((id) => { | ||
const sibling = pendingSiblings[id]; | ||
if (sibling) { | ||
this._update(id, ...sibling); | ||
delete pendingSiblings[id]; | ||
} | ||
}); | ||
} | ||
@@ -110,11 +116,19 @@ | ||
function update(element, callback, store) { | ||
triggers.forEach(function(trigger) { | ||
trigger(id, element, callback, store); | ||
}); | ||
if (triggers.length) { | ||
triggers.forEach(function(trigger) { | ||
trigger(id, element, callback, store); | ||
}); | ||
} else { | ||
pendingSiblings[id] = [element, callback, store]; | ||
} | ||
} | ||
function destroy(callback) { | ||
triggers.forEach(function(trigger) { | ||
trigger(id, null, callback); | ||
}); | ||
if (pendingSiblings[id]) { | ||
delete pendingSiblings[id]; | ||
} else { | ||
triggers.forEach(function(trigger) { | ||
trigger(id, null, callback); | ||
}); | ||
} | ||
} | ||
@@ -121,0 +135,0 @@ |
{ | ||
"version": "3.1.7", | ||
"version": "3.2.0", | ||
"name": "react-native-root-siblings", | ||
@@ -4,0 +4,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
129
9865
7