npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-blasted-image

v0.0.13

Published

A simple yet powerful image component for React Native, powered by Glide and SDWebImage

Downloads

2,125

Readme

:rocket: BlastedImage

npm downloads platform - android platform - ios

A simple yet powerful image component for React Native, powered by Glide (Android) and SDWebImage (iOS).

Description

Caching remote images has always been a challenge for me with the Image component in React Native. This simplified, yet powerful component, addresses that issue head-on. It offers a robust and performant mechanism for caching remote images, ensuring they're displayed quickly.Leveraging the strengths of Glide and SDWebImage, it supports both memory and disk caching for remote images. Notably, while it provides these enhanced capabilities for remote images, it seamlessly integrates with the standard React Native Image component when handling local assets.

Features

  • Performance: Bypasses the React Native Image component for remote images ensuring immediate and lightning-fast display of remote images.
  • Cross-Platform: Works on both Android (with Glide) and iOS (with SDWebImage)
  • Customizable: Wrapped within a View for added layout and style customization.
  • Robust Caching: Benefits from both memory and disk caching for maximum performance.

Installation

Using npm:

npm install react-native-blasted-image --save

Using yarn:

yarn add react-native-blasted-image

Link native packages (iOS only)

cd ios && pod install

Usage

Here's a simple example to get you started:

import BlastedImage from 'react-native-blasted-image';

<BlastedImage 
  source={{ uri: 'https://example.com/image.png' }} 
  resizeMode="cover"
  width={200}
  height={200}
  style={{ borderRadius: 10 }}
/>

Paramaters

| Parameter | Type | Description | Default | |--------------|-------------------|-----------------------------------------------------------------------------------------------------|---------| | source | Object or require | (Required) Can be an object containing a uri string for remote images or local images using require. | - | | width | Number | (Optional) Specifies the width of the image. Overrides width in style | 100 | | height | Number | (Optional) Specifies the height of the image. Overrides height in style | 100 | | resizeMode | String | (Optional) Resize the image with one of the options: cover contain center stretch | cover | | isBackground | Boolean | (Optional) Makes the image act as a container background similar to the native ImageBackground component | false | | fallbackSource | Object | (Optional) Object containing a uri string for a custom error image. | - | | onLoad | Function | (Optional) Callback function that gets called when the image has loaded succesfully. | - | | onError | Function | (Optional) Callback function that gets called when there was an error loading the image. | - | | style | Object | (Optional) Styles to be applied to the image, e.g., {borderRadius:20}.See View Style Props for all available styles. | - |

Methods

import BlastedImage from 'react-native-blasted-image';

BlastedImage.preload([
  { uri: 'https://example.com/image1.jpg' },
  { uri: 'https://example.com/image2.jpg', skipMemoryCache: true },
]);

| Method | PropType | Description | |---------------------------------|---------------------------|----------------------------------------------------------| | BlastedImage.preload() | Array<{ uri: string, skipMemoryCache: bool }> | Preloads remote images from an array of URIs, with the option to preload only to disk. | | BlastedImage.clearDiskCache() | - | Clears the disk cache for all images. | | BlastedImage.clearMemoryCache()| - | Clears the memory cache for all images. | | BlastedImage.clearAllCaches() | - | Clears both disk and memory caches for all images. |

Events

import { NativeEventEmitter, NativeModules } from 'react-native';

const BlastedImageEvents = new NativeEventEmitter(NativeModules.BlastedImage);

useEffect(() => {
  const subscription = BlastedImageEvents.addListener('BlastedEventLoaded', (data) => {
    console.log(data.message);
  });

  return () => {
    subscription.remove();
  };
}, []);

| Event | Description | |---------------------------------|-------------------------------------------------------------------| | BlastedEventLoaded | Triggered when remote images are successfully loaded. | | BlastedEventClearedMemory | Triggered when the memory cache for all images is cleared. | | BlastedEventClearedDisk| Triggered when the disk cache for all images is cleared. | | BlastedEventClearedAll | Triggered when both disk and memory caches for all images are cleared. |

Credits

This component was created with inspiration from react-native-fast-image that also uses Glide and SDWebImage. But due to its lack of ongoing maintenance i felt the need to develop this new image component to continue providing robust and performant caching functionality.

Contributing

Contributions are welcome! If you find a bug or have a feature request, please open an issue. If you want to contribute code, please open a pull request.

License

  • BlastedImage - MIT :copyright: xerdnu
  • SDWebImage - MIT
  • Glide - BSD, part MIT and Apache 2.0. See the LICENSE file for details.