mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 04:35:36 +08:00
[ReactNative] Register assets with AssetRegistry
This commit is contained in:
20
Libraries/Image/AssetRegistry.js
Normal file
20
Libraries/Image/AssetRegistry.js
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Copyright 2004-present Facebook. All Rights Reserved.
|
||||
*
|
||||
* @providesModule AssetRegistry
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var assets = [];
|
||||
|
||||
function registerAsset(asset) {
|
||||
// `push` returns new array length, so the first asset will
|
||||
// get id 1 (not 0) to make the value truthy
|
||||
return assets.push(asset);
|
||||
}
|
||||
|
||||
function getAssetByID(assetId) {
|
||||
return assets[assetId - 1];
|
||||
}
|
||||
|
||||
module.exports = { registerAsset, getAssetByID };
|
||||
Reference in New Issue
Block a user