Coder Social home page Coder Social logo

kosbog / react-native-offline-cache-webview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dgoenka/react-native-offline-cache-webview

0.0 1.0 0.0 503 KB

Offline cache enabled WebView, works for Android and iOS(WIP)

License: MIT License

JavaScript 6.28% Java 32.77% Python 1.46% Objective-C 59.50%

react-native-offline-cache-webview's Introduction

react-native-offline-cache-webview

Features

Offline cache enabled WebView, works for Android and iOS.

iOS Android

Install

npm i react-native-offline-cache-webview --save
react-native link react-native-offline-cache-webview

Usage

import OfflineCacheWebView from 'react-native-offline-cache-webview';
export default class webview extends Component {
    render() {
        return (
            <OfflineCacheWebView
                style={styles.webview}
                source={{uri: 'http://facebook.github.io/react-native/blog/2018/06/14/state-of-react-native-2018'}}
            />
        );
    }
}

Example

How does this work?

For iOS, the offline cache is implemented with RNCachingURLProtocol

RNCachingURLProtocol is a simple shim for the HTTP protocol (that’s not nearly as scary as it sounds). Anytime a URL is downloaded, the response is cached to disk. Anytime a URL is requested, if we’re online then things proceed normally. If we’re offline, then we retrieve the cached version.

For Android, it's provided by CacheWebView

CacheWebView is a custom implement of Android WebView resource interceptor. It beyond system WebView cache space limit, let cache config more simple ,fast and flexible. Visit website by offline.

This library is built on top of react-native-advanced-webview, the architecture leveraged for customizing React Naitve WebView

TODO

  • offlineCacheMode property to control on/off for cache usage
  • prefetch method for caching url by advance
  • clearCache method

References

react-native-offline-cache-webview's People

Contributors

dgoenka avatar greedbell avatar magicismight avatar wsong910 avatar zhangtaii avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.