Boa: Add examples

Created on 2 Jun 2020  路  5Comments  路  Source: boa-dev/boa

Current situation
We currently have no code examples to use the API externally both in the API documentation and in the nonexistent examples folder.

What do we need?
As mentioned in #445, we should be creating a new API, but in any case, we would need to create examples for some common use cases of Boa. I'm extracting here part of that discussion:

When a user wants to use Boa for their projects, I can imagine the following use cases:

  • They want to interpret JavaScript from a file or a stored String and get the result.
  • They want to interpret JavaScript that is coming from a socket with a Read interface and get the result by streaming the bytes.
  • They want to extend our engine by providing new global functions and objects, so that with the JavaScript they can either perform more rich things in their setup (for example by providing an API for a browser window), or because they want to add JavaScript helpers for common actions in their setup. This also includes things as being the scripting language of a complex platform.
  • They want to change the global object, for example, because they want it to be the window or a frame.

I think we need at least one example of each, that gets tested on each commit, in the examples directory of the boa crate. Then, I would add parts of those examples to the library-level documentation, in order to make life easier for our users.

enhancement help wanted good first issue documentation API

Most helpful comment

@Razican the examples are completed except for point 4, i am not sure if I have figured that out. I will raise a pull request now

All 5 comments

@Razican I can help with this.

@Razican I can help with this.

Go ahead! Thanks :)

@Razican the examples are completed except for point 4, i am not sure if I have figured that out. I will raise a pull request now

@Razican should this be on hold until we know what the public API will look like?

I think so, yes. But the public API is already pretty good, so some examples can be added.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

attliaLin picture attliaLin  路  3Comments

elasmojs picture elasmojs  路  5Comments

hello2dj picture hello2dj  路  5Comments

HalidOdat picture HalidOdat  路  3Comments

jasonwilliams picture jasonwilliams  路  6Comments