mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 19:45:05 +01:00
Add type annotations to common
This commit is contained in:
parent
e53f3d23d5
commit
bf53449f66
@ -14,9 +14,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
import {BaseObservableList} from "./BaseObservableList";
|
||||||
|
|
||||||
/* inline update of item in collection backed by array, without replacing the preexising item */
|
/* inline update of item in collection backed by array, without replacing the preexising item */
|
||||||
export function findAndUpdateInArray(predicate, array, observable, updater) {
|
export function findAndUpdateInArray<T>(predicate: (value: T) => boolean, array: T[], observable: BaseObservableList<T>, updater: (value: T) => any | false) {
|
||||||
const index = array.findIndex(predicate);
|
const index = array.findIndex(predicate);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
const value = array[index];
|
const value = array[index];
|
||||||
|
Loading…
Reference in New Issue
Block a user