Skip to content

lasimon/nativescript-pulltorefresh

 
 

Repository files navigation

npm npm

NativeScript-PullToRefresh ♻️

NativeScript plugin to use Pull to Refresh on any view.

Sample Screen

Android iOS
Android Sample iOS Sample

Installation

npm install nativescript-pulltorefresh

Usage

<page xmlns="http://schemas.nativescript.org/tns.xsd"
      xmlns:PullRefresh="nativescript-pulltorefresh"
      loaded="pageLoaded">
    <stack-layout>   
        <PullRefresh:PullToRefresh refresh="refreshList">
            <list-view items="{{ users }}">
                <list-view.itemTemplate>
                    <label text="{{ name }}" row="0" col="1" textWrap="true" class="message" />                            
                </list-view.itemTemplate>
            </list-view>
        </PullRefresh:PullToRefresh>        
    </stack-layout>
</page>

function refreshList(args) {

    // Get reference to the PullToRefresh;
    var pullRefresh = args.object;

    // Do work here... and when done call set refreshing property to false to stop the refreshing
    loadItems().then(function (resp) {
        // ONLY USING A TIMEOUT TO SIMULATE/SHOW OFF THE REFRESHING
        setTimeout(function () {
            pullRefresh.refreshing = false;
        }, 1000);
    }, function (err) {
        pullRefresh.refreshing = false;
    });
}
exports.refreshList = refreshList;

Attributes

refresh : function required

API

refreshing

Property. Notifies the widget that the refresh state has changed.

About

♻️ NativeScript plugin for PullToRefresh controls ♻️

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 78.8%
  • JavaScript 17.7%
  • CSS 3.5%