1657668120
A web UI framework inspired by React. An UI is built of components and components are built of DOM elements. Components can be stateless or stateful.
The entrypoint of a Deact application is the deact()
function. It requires a selector string and a function, that returns the root node of the application. The selector string is used to query a host element from the DOM.
All elements beneath the host element will be deleted and replaced by the provided root node.
A node can be a DOM element, a text or a component.
import 'package:deact/deact.dart';
import 'package:deact/deact_html52.dart';
void main() {
deact(
'#root',
div(children: [txt('Hello World')]),
);
}
In the example above, a div
element with the text Hello World
is added beneath the DOM element with the id root
.
If an application becomes more complex, it is advisable to separate the UI into smaller reusable chunks. Here, components come into play. A component is a function that returns a node. As a normal Dart function, a component can have parameters to configure the component.
import 'package:deact/deact.dart';
import 'package:deact/deact_html52.dart';
void main() {
deact(
'#root',
fragment([
coloredText('I am blue.', 'blue'),
coloredText('I am red.', 'red'),
]));
}
DeactNode coloredText(String text, String color) => fc((_) {
return div(style: 'color: $color', children: [txt(text)]);
});
In this example a component with the name coloredText
is introduced. The name itself is irrelevant for Deact and just helps to give the component a meaningful description.
To really create a component (in a Deact way), the function fc()
has to be used. The only parameter of the fc()
function is a builder function that has to return a node and accepts a ComponentContext
. This is required to use component-specific functionality of Deact.
A component can have a state. To access the state of a component, the function state()
of the ComponentContext
is used. A state has a name and a type.
DeactNode statefulComponent() => fc((ctx) {
final counter = ctx.state<int>('counter', 0);
return div(onclick: (_) => counter.set((c) => c + 1), children: [txt('Counter: ${counter.value}')]);
});
In the example above a state with the name counter
and the initial value 0
is created. A state is represented by an instance of the State
class. The actual value of a state can be accessed by the getter value
. To set a new value for the state, the function set()
or the setter value
is used. Alternatively, when the value of a state is a more compley type and only parts of it should be updated, the function update()
can be used. In both cases, the component and all its children will be rerendered after the state value was updated.
State created by the function state()
is local to the component. If it is required to share state over multiple components, a GlobalStateProviderComponent
can be used. A global state provider is a node and thus, it can be placed everywhere in the node hierarchy. Every component beneath a global state provider can access the state of the provider using the method globalState()
of the ComponentContext
to read or update it like a local state.
void main() {
deact(
'#root',
(_) => globalState<int>(
name: 'counter',
initialValue: 0,
children: [
incrementor(),
display(),
],
));
}
DeactNode incrementor() => fc((ctx) {
final counter = ctx.globalState<int>('counter');
return button(onclick: (_) => counter.set((c) => c + 1), children: [txt('Click me to increment to counter')]);
});
DeactNode display() => fc((ctx) {
final counter = ctx.globalState<int>('counter');
return div(children: [txt('Counter: ${counter.value}')]);
});
Above, a global state with name counter
and the initial value 0
is introduced on the top level of the node hierarchy. The components incrementor
and display
are children of the provider. The component incrementor
updates the state and the component display
reads the state.
It is also possible to let a component implement the interface GlobalStateProvider
. In this case, all local states of the compoenent is global to all its children.
An effect is a function, that may be called if
A component can have multiple effects and for each effect, it can be configured on which event it will be triggered.
An effect can have a cleanup function. The cleanup is called depending how the corresponding effect is configured.
If the effect is called when the component was added to the node hierarchy, the cleanup will called, when the component was removed from the hierarchy. If the effect is called on every rerender or in succession to a state change, the cleanup will be called before the effect is called the next time.
DeactNode componentWithEffect() => fc((ctx) {
final counter = ctx.state<int>('counter', 0);
ctx.effect('myEffect', () {
// do something...
...
return () {
// do some cleanup...
...
};
}, [counter]);
...
});
In the example above, the effect myEffect
is executed every time the state counter
has changed. The effect depends on the state counter
. The function return by the effect is the cleanup function. The cleanup is executed before the next time, the effect is executed.
If the effect depends on an empty list of states, the effect is only executed, when the component is added to the node hierarchy. The cleanup function is called, when the component is removed from the node hierarchy.
If null
is provided as the list of dependencies, the effect is executed every time the component rerenders. The cleanup is executed before the next time, the effect is executed (but not before the first time the effect is executed).
Examples for the usage of effects are
A reference holds a reference to a value. A reference can be local or global. A reference persists until the component, which has created the reference is removed from the node hierarchy. Changing the reference value will NOT force the component to rerender.
A local reference is created by calling the ref()
method of the ComponentContext
. A reference has a name and an optional initial value. The value of the reference can be accessed by value
memeber.
A special way to set the value of a reference is to provide the reference to the ref
parameter of an element node.
DeactNode refs() => fc((ctx) {
final inputRef = ctx.ref<InputElement?>('input');
return fragment([
button(
onclick: (_) => inputRef.value?.focus(),
children: [txt('Click me to focus the input element!')],
),
input(ref: inputRef),
]);
});
In this example, a reference to a InputElement
is created. The initial value is null
. The reference is provided as parameter to the input()
function. When the underlying DOM element is created, it is assigned to value of the reference.
A global reference is introduced using the function globalRef()
which creates an instance of a GloablRefProviderComponent
component. All children of this component can access the global reference by calling the gloablRef<T>(String)
method of the ComponentContext
. The same rules of how to find a global state apply here.
void main() {
deact(
'#root',
(_) => globalRef<int>(
name: 'counter',
initialValue: 0,
children: [
incrementor(),
display(),
],
));
}
DeactNode incrementor() => fc((ctx) {
final counter = ctx.globalRef<int>('counter');
return button(
onclick: (_) => counter.value = counter.value + 1,
children: [txt('Click me to increment to counter')],
);
});
DeactNode display() => fc((ctx) {
final counter = ctx.state<int>('counter', 0);
ctx.effect('init', () {
// listen to changes of the value of the 'counter' reference
ctx.globalRef<int>('counter').onChange.listen((c) {
// update the internal state of the display component.
// this forces the component to be rerendered. but you
// do some stuff, that do not force a rerender.
counter.value = c;
});
return null;
}, dependsOn: []);
return div(children: [txt('Counter: ${counter.value}')]);
}, key: 'display');
As you can see, a reference provices a stream of value change events.
It is also possible to let a component implement the interface GlobalRefProvider
. In this case, all local references of the compoenent is global to all its children.
Run this command:
With Dart:
$ dart pub add deact
With Flutter:
$ flutter pub add deact
This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get
):
dependencies:
deact: ^1.2.0
Alternatively, your editor might support dart pub get
or flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:deact/deact.dart';
example/README.md
Examples
A very simple Deact application that display Hello World
.
Show the usage of components.
Shows the usage of effects.
Shows the usage of global references.
Shows the usage of global state.
A simple Hello World application.
A Deact implementation of the application as decribed at How to Benchmark React Components: The Quick and Dirty Guide
Shows the usage of references.
Shows the usage of component local state.
Deact has no stable release yet. Functionality is not yet complete. The API may change and maybe in a breaking way.
Actually, Deact is tested in an internal project.
If you will try Deact: Feedback is welcome!
Original article source at: https://pub.dev/packages/deact
1598839687
If you are undertaking a mobile app development for your start-up or enterprise, you are likely wondering whether to use React Native. As a popular development framework, React Native helps you to develop near-native mobile apps. However, you are probably also wondering how close you can get to a native app by using React Native. How native is React Native?
In the article, we discuss the similarities between native mobile development and development using React Native. We also touch upon where they differ and how to bridge the gaps. Read on.
Let’s briefly set the context first. We will briefly touch upon what React Native is and how it differs from earlier hybrid frameworks.
React Native is a popular JavaScript framework that Facebook has created. You can use this open-source framework to code natively rendering Android and iOS mobile apps. You can use it to develop web apps too.
Facebook has developed React Native based on React, its JavaScript library. The first release of React Native came in March 2015. At the time of writing this article, the latest stable release of React Native is 0.62.0, and it was released in March 2020.
Although relatively new, React Native has acquired a high degree of popularity. The “Stack Overflow Developer Survey 2019” report identifies it as the 8th most loved framework. Facebook, Walmart, and Bloomberg are some of the top companies that use React Native.
The popularity of React Native comes from its advantages. Some of its advantages are as follows:
Are you wondering whether React Native is just another of those hybrid frameworks like Ionic or Cordova? It’s not! React Native is fundamentally different from these earlier hybrid frameworks.
React Native is very close to native. Consider the following aspects as described on the React Native website:
Due to these factors, React Native offers many more advantages compared to those earlier hybrid frameworks. We now review them.
#android app #frontend #ios app #mobile app development #benefits of react native #is react native good for mobile app development #native vs #pros and cons of react native #react mobile development #react native development #react native experience #react native framework #react native ios vs android #react native pros and cons #react native vs android #react native vs native #react native vs native performance #react vs native #why react native #why use react native
1595344320
Corona Virus Pandemic has brought the world to a standstill.
Countries are on a major lockdown. Schools, colleges, theatres, gym, clubs, and all other public places are shut down, the country’s economy is suffering, human health is on stake, people are losing their jobs and nobody knows how worse it can get.
Since most of the places are on lockdown, and you are working from home or have enough time to nourish your skills, then you should use this time wisely! We always complain that we want some ‘time’ to learn and upgrade our knowledge but don’t get it due to our ‘busy schedules’. So, now is the time to make a ‘list of skills’ and learn and upgrade your skills at home!
And for the technology-loving people like us, Knoldus Techhub has already helped us a lot in doing it in a short span of time!
If you are still not aware of it, don’t worry as Georgia Byng has well said,
“No time is better than the present”
– Georgia Byng, a British children’s writer, illustrator, actress and film producer.
No matter if you are a developer (be it front-end or back-end) or a data scientist, tester, or a DevOps person, or, a learner who has a keen interest in technology, Knoldus Techhub has brought it all for you under one common roof.
From technologies like Scala, spark, elastic-search to angular, go, machine learning, it has a total of 20 technologies with some recently added ones i.e. DAML, test automation, snowflake, and ionic.
Every technology in Tech-hub has n number of templates. Once you click on any specific technology you’ll be able to see all the templates of that technology. Since these templates are downloadable, you need to provide your email to get the template downloadable link in your mail.
These templates helps you learn the practical implementation of a topic with so much of ease. Using these templates you can learn and kick-start your development in no time.
Apart from your learning, there are some out of the box templates, that can help provide the solution to your business problem that has all the basic dependencies/ implementations already plugged in. Tech hub names these templates as xlr8rs (pronounced as accelerators).
xlr8rs make your development real fast by just adding your core business logic to the template.
If you are looking for a template that’s not available, you can also request a template may be for learning or requesting for a solution to your business problem and tech-hub will connect with you to provide you the solution. Isn’t this helpful 🙂
To keep you updated, the Knoldus tech hub provides you with the information on the most trending technology and the most downloaded templates at present. This you’ll be informed and learn the one that’s most trending.
Since we believe:
“There’s always a scope of improvement“
If you still feel like it isn’t helping you in learning and development, you can provide your feedback in the feedback section in the bottom right corner of the website.
#ai #akka #akka-http #akka-streams #amazon ec2 #angular 6 #angular 9 #angular material #apache flink #apache kafka #apache spark #api testing #artificial intelligence #aws #aws services #big data and fast data #blockchain #css #daml #devops #elasticsearch #flink #functional programming #future #grpc #html #hybrid application development #ionic framework #java #java11 #kubernetes #lagom #microservices #ml # ai and data engineering #mlflow #mlops #mobile development #mongodb #non-blocking #nosql #play #play 2.4.x #play framework #python #react #reactive application #reactive architecture #reactive programming #rust #scala #scalatest #slick #software #spark #spring boot #sql #streaming #tech blogs #testing #user interface (ui) #web #web application #web designing #angular #coronavirus #daml #development #devops #elasticsearch #golang #ionic #java #kafka #knoldus #lagom #learn #machine learning #ml #pandemic #play framework #scala #skills #snowflake #spark streaming #techhub #technology #test automation #time management #upgrade
1619172468
Web development frameworks are a powerful answer for businesses to accomplish a unique web app as they play a vital role in providing tools and libraries for developers to use.
Most businesses strive to seek offbeat web applications that can perform better and enhance traffic to the site. Plus, it is imperative to have such apps as the competition is very high in the digital world.
Developers find it sophisticated to use the libraries and templates provided by frameworks to make interactive and user-friendly web applications. Moreover, frameworks assist them in increasing the efficiency, performance, and productivity of the web development task.
Before getting deep into it, let’s have a quick glance at the below facts and figures below that will help you comprehend the utility of the frameworks.
As per Statista, 35.9% of developers used React in 2020.
25.1% of developers used the Angular framework worldwide.
According to SimilarTech, 2,935 websites use the Spring framework, most popular among the News and Media domain.
What is a Framework?
A framework is a set of tools that paves the way for web developers to create rich and interactive web apps. It comprises libraries, templates, and specific software tools. Additionally, it enables them to develop a hassle-free application by not rewriting the same code to build the application.
There are two categories of frameworks: the back-end framework, known as the server-side, and the front-end framework, known as the client-side.
The backend framework refers to a web page portion that you can not see, and it communicates with the front end one. On the other hand, the front-end is a part of the web that users can see and experience.
You can understand by an example that what you see on the app is the front-end part, and the communication you make with it is the part of the back end.
Read the full blog here
Hence, depending on your web development application requirements, you can hire web developers from India’s best web development company. In no time, you will be amongst those who are reaping the results of using web development frameworks for the applications.
#web-development-frameworks #web-frameworks #top-web-frameworks #best-web-development-frameworks
1613122689
Golang is one of the most powerful and famous tools used to write APIs and web frameworks. Google’s ‘Go’ otherwise known as Golan orders speedy running local code. It is amazing to run a few programming advancements rethinking specialists and software engineers from various sections. We can undoubtedly say that this is on the grounds that the engineers have thought that it was easiest to utilize Go. It is always considered as ago for web and mobile app development because it is ranked highest among all the web programming languages.
Top 3 Golang web frameworks in 2021:
1.Martini: Martini is said to be a low-profile framework as it’s a small community but also known for its various unique things like injecting various data sets or working on handlers of different types. It is very active and there are some twenty and above plug-ins which could also be the reason for the need for add-ons. It deals with some principles of techniques like routing, dealing, etc, basic common tricks to do middleware.
2.Buffalo: Buffalo is known for its fast application development services. It is a complete process of starting any project from scratch and providing end to end facility for back-end web building. Buffalo comes with the dev command which helps directly to experience transformations in front of you and redevelop your whole binary. It is rather an ecosystem used to create the best app development.
3.Gorilla: Gorilla is the largest and longest-running Go web framework. It can be little and maximum for any user. It is also the biggest English-speaking community that comes with robust web sockets features so you can attach the REST codes to the endpoints giving a third-party service like Pusher.
So, these are some web frameworks that can be used for Golang language. Each framework has its unique points which are only found in them but all of them are the best. IF your developer is in search of one this is where you can find the best.
#top 3 golang web frameworks in 2021 #golang #framework #web-service #web #web-development
1651604400
React Starter Kit is an opinionated boilerplate for web development built on top of Node.js, Express, GraphQL and React, containing modern web development tools such as Webpack, Babel and Browsersync. Helping you to stay productive following the best practices. A solid starting point for both professionals and newcomers to the industry.
See getting started guide, demo, docs, roadmap | Join #react-starter-kit chat room on Gitter | Visit our sponsors:
The master
branch of React Starter Kit doesn't include a Flux implementation or any other advanced integrations. Nevertheless, we have some integrations available to you in feature branches that you can use either as a reference or merge into your project:
master
)feature/redux
)feature/apollo
)master
)You can see status of most reasonable merge combination as PRs labeled as TRACKING
If you think that any of these features should be on master
, or vice versa, some features should removed from the master
branch, please let us know. We love your feedback!
React Starter Kit
| React Static Boilerplate
| ASP.NET Core Starter Kit
| |
---|---|---|---|
App type | Isomorphic (universal) | Single-page application | Single-page application |
Frontend | |||
Language | JavaScript (ES2015+, JSX) | JavaScript (ES2015+, JSX) | JavaScript (ES2015+, JSX) |
Libraries | React, History, Universal Router | React, History, Redux | React, History, Redux |
Routes | Imperative (functional) | Declarative | Declarative, cross-stack |
Backend | |||
Language | JavaScript (ES2015+, JSX) | n/a | C#, F# |
Libraries | Node.js, Express, Sequelize, GraphQL | n/a | ASP.NET Core, EF Core, ASP.NET Identity |
SSR | Yes | n/a | n/a |
Data API | GraphQL | n/a | Web API |
♥ React Starter Kit? Help us keep it alive by donating funds to cover project expenses via OpenCollective or Bountysource!
Anyone and everyone is welcome to contribute to this project. The best way to start is by checking our open issues, submit a new issue or feature request, participate in discussions, upvote or downvote the issues you like or dislike, send pull requests.
Copyright © 2014-present Kriasoft, LLC. This source code is licensed under the MIT license found in the LICENSE.txt file. The documentation to the project is licensed under the CC BY-SA 4.0 license.
Author: kriasoft
Source Code: https://github.com/kriasoft/react-starter-kit
License: MIT License