new geo.fileReader(arg){geo.fileReader}
Create a new instance of class fileReader.
Name | Type | Description |
---|---|---|
arg |
geo.fileReader.spec | optional |
Returns:
Type | Description |
---|---|
geo.fileReader |
Extends
Type Definitions
-
geo.fileReader.specobject
-
Object specification for a fileReader.
Properties:
Name Type Argument Description layer
geo.featureLayer <optional>
The target feature layer.
Members
-
inherited idle
-
Getter for the idle state. Read only.
Properties:
Name Type Description idle
boolean true
if the object is idle (onIdle
would call a handler immediately).
Methods
-
Add a new promise object preventing idle event handlers from being called until it is resolved.
Name Type Description promise
Promise A promise object.
Returns:
Type Description this -
canRead(file){boolean}
-
Tells the caller if it can handle the given file by returning a boolean.
Name Type Description file
File | Blob | string | object This is either a
File
object, aBlob
object, a string representation of a file, or an object representing data from a file.Returns:
Type Description boolean true
if this reader can read a file. -
Report if an event handler is bound to this object.
Name Type Description event
string | Array.<string> An event or list of events to check.
handler
function optional A function that might be bound. If
undefined
, this will reporttrue
if there is any handler for the specified event.Returns:
Type Description boolean true if any of the specified events are bound to the specified handler. -
Remove handlers from one event or an array of events. If no event is provided all handlers will be removed.
Name Type Description event
string | Array.<string> optional An event or a list of events from
geo.event
or defined by the user, orundefined
to remove all events (in which casearg
is ignored).arg
function | Array.<function()> optional nullable A function or array of functions to remove from the events or a falsy value to remove all handlers from the events.
Returns:
Type Description this -
Bind an event handler to this object.
Name Type Description event
string An event from
geo.event
or a user-defined value.handler
function A function that is called when
event
is triggered. The function is passed ageo.event
object.Returns:
Type Description this -
Bind an event handler to this object that will fire once and then deregister itself.
Name Type Description event
string An event from
geo.event
or a user-defined value.handler
function A function that is called when
event
is triggered. The function is passed ageo.event
object.Returns:
Type Description function The actual bound handler. This is a wrapper around the handler that was passed to the function. -
Trigger an event (or events) on this object and call all handlers.
Name Type Description event
string | Array.<string> An event or list of events from
geo.event
or defined by the user.args
object optional Additional information to add to the
geo.event
object passed to the handlers.Returns:
Type Description this -
layer(){geo.featureLayer}
-
Get the feature layer attached to the reader.
Returns:
Type Description geo.featureLayer The layer associated with the reader. -
inherited modified(){this}
-
Update the timestamp to the next global timestamp value.
Returns:
Type Description this -
Bind a handler that will be called one time when all internal promises are resolved. If there are no outstanding promises, this is invoked synchronously.
Name Type Description handler
function A function taking no arguments.
Returns:
Type Description this -
read(file, done, progress){Promise}
-
Reads the file and optionally calls a function when finished. The
done
function is called with a value that is truthy if the read was a success. Depending on the specific reader, this value may be an object with details of the read operation.Name Type Description file
File | Blob | string | object This is either a
File
object, aBlob
object, a string representation of a file, or an object representing data from a file.done
function optional An optional callback function when the read is complete. This is called with
false
on error or the object that was read and parsed by the reader.progress
function optional A function which is passed
ProgressEvent
information from aFileReader
. This includesloaded
andtotal
each with a number of bytes.Returns:
Type Description Promise A Promise
that resolves with object parsed by the reader or is rejected if the reader fails. -
Mark a promise as no longer required to resolve before the idle state is reached.
Name Type Description promise
Promise A promise object.
Returns:
Type Description this -
inherited timestamp(){number}
-
Get time.
Returns:
Type Description number The timestamp. This is 0 if the timestamp has never been modified. -
innernewFileReader(done, progress){FileReader}
-
Return a
FileReader
with handlers attached.Name Type Description done
function A callback that receives either the string read from the file or a
DOMException
with an error.progress
function optional A function which is passed
ProgressEvent
information from aFileReader
. This includesloaded
andtotal
each with a number of bytes.Returns:
Type Description FileReader The FileReader
with done and progress handles attached to it.