parse-loader
This is a class that helps you develop when you need to get results from a Parse backend.
Installation
$> npm i --save parse-loader
API
; //... let's create a Parse.Query for the exampleconst q = 'MyClass'; // ParseLoader(query, limit, skip)const loader = q 10 0; // returns the first item on the query, using ES2015 promisesloader; // Promise<Parse.Object> // returns the first item on the query, using ES2015 promisesloader; // Promise<Parse.Object[]> // restarts finding at skip 0loader; // Promise<Parse.Object[]> // says if you can load more (only available after first find)loader; // boolean // loads items infinitely from a Parse Databaseloader; // Promise<Parse.Object[]> // loads items infinitely (backwards) from a Parse Databaseloader; // Promise<Parse.Object[]> // reloads the current searchloader; // Promise<Parse.Object[]>
Examples
Finding elements from a query in a paginated, infinite way
Lets say for the example, that we are in an app where the user finds messages sent to them. In this app, when the user scrolls to the bottom of the page, the list of messages is filled with more results from the database.
Please note the example does not use any framework in specific. This works on all of them, so it doesn't matter if you use Angular, React, Ember, Aurelia ... (you name it).
; //... let's create a Parse.Query for the exampleconst q = 'MyClass'; // create the loaderconst loader = q 10 0; // function that triggers when the user first enters the page { loader ;} // when the user reloads the page somehow{ loader ;} // function that executes when the user reached the bottom of the page { loader ;}
Bonus
- This package has no external dependencies :D
- #findNext takes into account if the search had any errors and repeats the same search
LICENSE
MIT
Developed by Juan Camilo Guarín Peñaranda
Otherwise SAS, Colombia, 2017