iohk-training's People
iohk-training's Issues
Only generate data once if there is none
Currently you re-generate the invoices data on every server restart, which is fine for this example app but it would be more elegant to only generate the data if it does not exist yet ๐
Window scroll listener now removed onDestroy of template
If you your app would rerender your component in various situations your $(window).scroll
event listeners would not be cleaned up correctly!
Optimize for readability
In general the code looks good but in some cases it would be nice to cleanup the formatting and avoid splitting up code flow into too many functions unnecessarily.
One example are imports:
import {
Invoices
} from '../api/invoices'
can and should be a simple one-liner:
import { Invoices } from '../api/invoices';
Here you split the code up into many small functions which is nice for big apis and when there is real complexity going on. But this component is so simple that this is less readable in the end!
function areAllLoaded( data ) {
return data.total === data.loaded
}
function isIndicatorVisible( window, target ) {
const threshold = window.scrollTop() + window.height() - target.height();
return target.offset().top < threshold;
}
function tryLoadMoreData( instance ) {
var target = instance.$( "#load-more" );
if ( !target.length ) return;
if ( isIndicatorVisible( $( window ), target ) && !areAllLoaded( instance.data ) ) {
instance.data.onNeedMoreItems()
}
}
Template.InfiniteScroll.onRendered( function onBodyCreated() {
$( window ).scroll( () => {
tryLoadMoreData( this )
} )
} )
Template.InfiniteScroll.helpers( {
allLoaded() {
return areAllLoaded( this )
},
moreToLoad() {
return !areAllLoaded( this )
}
} )
you could pack this code into ~20-30 lines of code instead, as simple as possible ๐
No default route on "/"
Currently there is just the iron router error page showing up that there is no route defined for the URL path "/"
. Would be nice to add a redirect for that ๐
total-invoices count must represent current query
Currently you return the total count of all invoices but the client actually needs to know how many invoices there are for the current set of filter and sorting options! This means you have to use the same query for the total count too.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.