matteoterrinoni / portfolio Goto Github PK
View Code? Open in Web Editor NEWMy portfolio App based on React-boilerplate and firebase
Home Page: http://www.matteoterrinoni.it/
License: MIT License
My portfolio App based on React-boilerplate and firebase
Home Page: http://www.matteoterrinoni.it/
License: MIT License
If you have time can you help me understand how this works? (From line 45 in your file)
const channel = eventChannel(emit => task.on('state_changed', emit));
yield takeEvery(channel, (s)=>percentage(s, reducer));
How does the task.on
know what do to with the emit
item with extra code?
I took what you had and got it working in my code below but I would like to know how it works.
export default class BeerTapSaga {
public static* percentage(snapshot: firebase.storage.UploadTaskSnapshot) {
const progress: number = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
yield put(BeerTapAction.addBeerTapImageProgress(progress));
}
public static* addBeerTapImage(action: IAction<File>) {
const file: File = action.payload;
try {
const storageRef: firebase.storage.Reference = FirebaseUtility.getStorage().ref(`folder_name/${file.name}`);
const uploadTask: firebase.storage.UploadTask = storageRef.put(file);
const channel: Channel<any> = eventChannel((emit) => uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, emit) as any);
yield takeEvery(channel, (snapshot: firebase.storage.UploadTaskSnapshot) => BeerTapSaga.percentage(snapshot));
yield uploadTask; // Wait for upload to complete
yield put(BeerTapAction.addBeerTapImageSuccess(uploadTask.snapshot.downloadURL));
} catch (error) {
yield put(ErrorAction.requestFailure(error));
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.