Skip to content

Conversation

@BartoszKlonowski
Copy link
Member

This pull request provides the application with the ability to show all the notes created in the application.

It pulls the notes from the database once the main page is opened.


The flow of the data starts when the main page is entered: first, the number of notes is taken from the database, according to that number all the keys are created as the object: {key: ID}, where the ID is incremented by 1 starting from 0.
Those generated keys are sent to the <FlatList/> which renders all the notes.
For each NoteWidget the Title and Short message is pulled from Database handler using the given ID.

There are many changes done for the flow to work, so please reach out to the commit messages for more details.


The results are as follows:
RNN-Example3

This implementation adds several methods to the Database handler class:
* GetNumberOfNotes - returns the number of notes already created by the
  user in the system. It considers only the size of the repository,
  without checking the correctness of the IDs.
* DoesIDExists - checks whether the notes with the given ID exists in
  the Database
* GetAllNotes - alternate version of creating the notes keys' method.
  It returns the array of already created objects containing the Key and
  it's value.
  This is experimental and not yet fully tested/supported.

Note that the `GetNumberOfNotes` method uses Promise instead of return
callback. This is due to the fact of async nature of native modules. So
to avoid losing the information of returned value when going out of the
return handler, the promise is used which carries the result.
The index can now be used as a parameter for all the CRUD operations
done on the Repository.
This is to allow the easier manipulations when it comes to all notes no
matter if they Id matches the db position.

The purpose of this implementation is to make sure that in the future
the index and the ID will be separate and the logic behind
adding/removing and displaying the content will be more flexible.
The Database native module has all the methods returning values used
asynchronously, but their results are considered as states on the JS
side.
To avoid loosing the data the Promise has been used to make the database
pull more dynamic.
@BartoszKlonowski BartoszKlonowski added enhancement New feature or request C++ Topic relates to the C++ native code JavaScript Topic relates to the JS or React Native code labels Apr 6, 2021
@BartoszKlonowski BartoszKlonowski merged commit 226c21f into main Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C++ Topic relates to the C++ native code enhancement New feature or request JavaScript Topic relates to the JS or React Native code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants