Core Elements
Here you will find the list of Linker Studio core elements.
Available for all users
TypeScript
This is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale. TypeScript adds additional syntax to JavaScript to support a tighter integration with your editor. Remember, all files must end in .ts.
It has many advantages like for example:
TypeScript understands JavaScript and uses type inference to give you great tooling without additional code.
It is more reliable and easier to refactor. This enables developers to evade errors and do rewrites much easier.
Access to ES6 and ES7 features, before they become supported by major browsers
Redux Toolkit
Redux Toolkit helps simplify Redux development. It includes utilities for creating and managing Redux stores, as well as for writing Redux actions and reducers.
Click here for more information about redux toolkit
This is an example of the structure for the redux folder.
In the Slice file we create the initial state, a section for selectors, and the setters.
If the Thunk file is necessary, it will have the asynchronous actions for when a request is needed to be made.
Eslint
ESLint statically analyzes the code to quickly find problems. It allows creating a series of assertions called lint rules around what the code should look or behave like, as well as auto-fixer suggestions to improve code for us, and loading in lint rules from shared plugins.
We have set up a the basic eslint configuration which is in the .eslintrc.js file.
To test eslint on your code, you can run the following command on the terminal:
Localization
This library helps us support multiple languages in the app based on the language configuration of the user's device. It helps organize all the strings that will be displayed to the user, avoiding hardcoded strings in the components. Each module will have a localization folder that contains each language in a different file. By default, it only supports English and stores those strings into an object in the en.ts
file.
To support another language, you will need the following:
Create a separate file for this language (e.g.,
es.ts
inside the localization folder for Spanish support). Create an exact copy of the currenten.ts
file and replace the quoted text with the translation for each string.Then, add the
es
object import to theLocalization.ts
file and add thees
object into theLocalizedStrings
object.
If your app doesn't support the user's device language, it will display English as the default language.
You can force a language programmatically with this code line:
Dates
To manage Dates and Time Zone, use the included libraries luxon and localize respectively. You can retrieve the user's Time Zone using localize to use it with the luxon date constructors.
Example of use: Retrieve user's current Date based on the user's device time zone.
You can find the following helper functions in the LinkerStudio/core/utils/date/Date.ts file:
getCurrentDate: Retrieves user's current date based on the user's device time zone.
getCurrentISODate: Returns the current
DateTime
based on the user's time zone in ISO format, example: '2017-04-22T20:47:05.335-04:00'.
isValidDate: Receives a string
date
and a stringformat
, and returns if the provideddate
is valid based on the providedformat
.
Last updated