Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added example for flush() #2570

Merged
merged 16 commits into from
Jan 25, 2018
Merged

Added example for flush() #2570

merged 16 commits into from
Jan 25, 2018

Conversation

hackertron
Copy link
Contributor

added example for Printwriter flush() method .
refering to this issue : #1954

@limzykenneth
Copy link
Member

Hi, could you add a brief description for the method, explaining what flush means and what it does? Thanks

@hackertron
Copy link
Contributor Author

Sure !!

src/io/files.js Outdated
@@ -1125,6 +1125,7 @@ p5.PrintWriter = function(filename, extension) {
this.content += data + '\n';
};
/**
* Flushes the PrintWriter object that calls it
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would actually go for something more descriptive, as "flush" means nothing to someone unfamiliar with a PrintWriter. Something like "Clears the data already written to the PrintWriter"

@hackertron
Copy link
Contributor Author

Description : Clears the data already written to the PrintWriter object 👍

@Spongman
Copy link
Contributor

Spongman commented Jan 23, 2018

the only issue i have with this is that it's not actually necessary to call flush() immediately before a call to close() since close calls flush() internally.

also, another weird thing, and this has nothing to do with your example, is that usually when you have a writer API with a flush() method, that method's action is usually to force writing the current contents of any buffers in the writer to its output. in p5's PrintWriter the flush() method just clears the internal buffer. i realize that this is because the write (usually) has to be done in one step since the downloadFile operation is on a Blob, not a stream. it sesms to me that a better name for this method would be clear() or reset().

@hackertron
Copy link
Contributor Author

@Spongman understood your first point but I just wanted to show flush example in it's simplest form .

@lmccart
Copy link
Member

lmccart commented Jan 25, 2018

@Spongman I see your point, but I think this is nice as a simple example. we can always add a second more complex example that demonstrates a clear use case.

@lmccart lmccart merged commit 8a34e3c into processing:master Jan 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants