mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
Add start_app method
This commit is contained in:
parent
cfe5d84b8c
commit
fc7f7a97ea
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
### New features
|
### New features
|
||||||
|
|
||||||
|
- Added `start_app` method. It's a shortcut to initialize a component and mount it to the body.
|
||||||
|
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
|
|
||||||
## 0.5 - Released 2019-02-01
|
## 0.5 - Released 2019-02-01
|
||||||
|
|||||||
@ -1,9 +1,5 @@
|
|||||||
extern crate stdweb;
|
|
||||||
#[macro_use]
|
|
||||||
extern crate yew;
|
|
||||||
|
|
||||||
use stdweb::web::Date;
|
use stdweb::web::Date;
|
||||||
use yew::prelude::*;
|
use yew::{html, Component, ComponentLink, Renderable, ShouldRender};
|
||||||
use yew::services::ConsoleService;
|
use yew::services::ConsoleService;
|
||||||
|
|
||||||
pub struct Model {
|
pub struct Model {
|
||||||
|
|||||||
@ -1,11 +1,3 @@
|
|||||||
extern crate yew;
|
|
||||||
extern crate counter;
|
|
||||||
|
|
||||||
use yew::prelude::*;
|
|
||||||
use counter::Model;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
yew::initialize();
|
yew::start_app::<counter::Model>();
|
||||||
App::<Model>::new().mount_to_body();
|
|
||||||
yew::run_loop();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,3 @@
|
|||||||
extern crate yew;
|
|
||||||
extern crate crm;
|
|
||||||
|
|
||||||
use yew::prelude::*;
|
|
||||||
use crm::Model;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
yew::initialize();
|
yew::start_app::<crm::Model>();
|
||||||
App::<Model>::new().mount_to_body();
|
|
||||||
yew::run_loop();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,3 @@
|
|||||||
extern crate yew;
|
|
||||||
extern crate custom_components;
|
|
||||||
|
|
||||||
use yew::prelude::*;
|
|
||||||
use custom_components::Model;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
yew::initialize();
|
yew::start_app::<custom_components::Model>();
|
||||||
App::<Model>::new().mount_to_body();
|
|
||||||
yew::run_loop();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,3 @@
|
|||||||
extern crate yew;
|
|
||||||
extern crate dashboard;
|
|
||||||
|
|
||||||
use yew::prelude::*;
|
|
||||||
use dashboard::Model;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
yew::initialize();
|
yew::start_app::<dashboard::Model>();
|
||||||
App::<Model>::new().mount_to_body();
|
|
||||||
yew::run_loop();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,3 @@
|
|||||||
extern crate yew;
|
|
||||||
extern crate fragments;
|
|
||||||
|
|
||||||
use yew::prelude::*;
|
|
||||||
use fragments::Model;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
yew::initialize();
|
yew::start_app::<fragments::Model>();
|
||||||
App::<Model>::new().mount_to_body();
|
|
||||||
yew::run_loop();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,4 @@
|
|||||||
extern crate yew;
|
use log::trace;
|
||||||
extern crate game_of_life;
|
|
||||||
|
|
||||||
#[macro_use] extern crate log;
|
|
||||||
extern crate web_logger;
|
|
||||||
|
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
use game_of_life::{Model, Msg};
|
use game_of_life::{Model, Msg};
|
||||||
|
|
||||||
@ -11,7 +6,7 @@ fn main() {
|
|||||||
web_logger::init();
|
web_logger::init();
|
||||||
trace!("Initializing yew...");
|
trace!("Initializing yew...");
|
||||||
yew::initialize();
|
yew::initialize();
|
||||||
App::<Model>::new().mount_to_body()
|
App::<game_of_life::Model>::new().mount_to_body()
|
||||||
.send_message(Msg::Random);
|
.send_message(Msg::Random);
|
||||||
yew::run_loop();
|
yew::run_loop();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,3 @@
|
|||||||
#![recursion_limit="512"]
|
|
||||||
extern crate stdweb;
|
|
||||||
extern crate yew;
|
|
||||||
extern crate inner_html;
|
|
||||||
|
|
||||||
use yew::prelude::*;
|
|
||||||
|
|
||||||
use inner_html::Model;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
yew::initialize();
|
yew::start_app::<inner_html::Model>();
|
||||||
App::<Model>::new().mount_to_body();
|
|
||||||
yew::run_loop();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,3 @@
|
|||||||
extern crate yew;
|
|
||||||
extern crate js_callback;
|
|
||||||
|
|
||||||
use yew::prelude::*;
|
|
||||||
use js_callback::Model;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
yew::initialize();
|
yew::start_app::<js_callback::Model>();
|
||||||
App::<Model>::new().mount_to_body();
|
|
||||||
yew::run_loop();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,3 @@
|
|||||||
extern crate yew;
|
|
||||||
extern crate large_table;
|
|
||||||
|
|
||||||
use yew::prelude::*;
|
|
||||||
use large_table::Model;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
yew::initialize();
|
yew::start_app::<large_table::Model>();
|
||||||
App::<Model>::new().mount_to_body();
|
|
||||||
yew::run_loop();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
yew::initialize();
|
yew::start_app::<minimal::Model>();
|
||||||
yew::App::<minimal::Model>::new().mount_to_body();
|
|
||||||
yew::run_loop();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,5 @@
|
|||||||
#[macro_use]
|
use yew::App;
|
||||||
extern crate stdweb;
|
use stdweb::web::{js, IElement, INode, IParentNode, document};
|
||||||
extern crate yew;
|
|
||||||
extern crate mount_point;
|
|
||||||
|
|
||||||
use yew::prelude::*;
|
|
||||||
use stdweb::web::{IElement, INode, IParentNode, document};
|
|
||||||
use mount_point::Model;
|
use mount_point::Model;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|||||||
@ -1,11 +1,3 @@
|
|||||||
extern crate yew;
|
|
||||||
extern crate npm_and_rest;
|
|
||||||
|
|
||||||
use yew::prelude::*;
|
|
||||||
use npm_and_rest::Model;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
yew::initialize();
|
yew::start_app::<npm_and_rest::Model>();
|
||||||
App::<Model>::new().mount_to_body();
|
|
||||||
yew::run_loop();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,3 @@
|
|||||||
extern crate yew;
|
|
||||||
extern crate routing;
|
|
||||||
|
|
||||||
use yew::prelude::*;
|
|
||||||
use routing::Model;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
yew::initialize();
|
yew::start_app::<routing::Model>();
|
||||||
App::<Model>::new().mount_to_body();
|
}
|
||||||
yew::run_loop();
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,11 +1,3 @@
|
|||||||
extern crate yew;
|
|
||||||
extern crate textarea;
|
|
||||||
|
|
||||||
use yew::prelude::*;
|
|
||||||
use textarea::Model;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
yew::initialize();
|
yew::start_app::<textarea::Model>();
|
||||||
App::<Model>::new().mount_to_body();
|
|
||||||
yew::run_loop();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,3 @@
|
|||||||
extern crate yew;
|
|
||||||
extern crate timer;
|
|
||||||
|
|
||||||
use yew::prelude::*;
|
|
||||||
use timer::Model;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
yew::initialize();
|
yew::start_app::<timer::Model>();
|
||||||
App::<Model>::new().mount_to_body();
|
|
||||||
yew::run_loop();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,4 @@
|
|||||||
extern crate yew;
|
|
||||||
extern crate todomvc;
|
|
||||||
|
|
||||||
use yew::prelude::*;
|
|
||||||
use todomvc::Model;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
yew::initialize();
|
yew::start_app::<todomvc::Model>();
|
||||||
App::<Model>::new().mount_to_body();
|
|
||||||
yew::run_loop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,3 @@
|
|||||||
extern crate stdweb;
|
|
||||||
extern crate yew;
|
|
||||||
extern crate two_apps;
|
|
||||||
|
|
||||||
use stdweb::web::{IParentNode, document};
|
use stdweb::web::{IParentNode, document};
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
use yew::html::Scope;
|
use yew::html::Scope;
|
||||||
|
|||||||
106
src/lib.rs
106
src/lib.rs
@ -104,56 +104,16 @@ pub fn run_loop() {
|
|||||||
stdweb::event_loop();
|
stdweb::event_loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The Yew Prelude
|
/// Starts an app mounted to a body of the document.
|
||||||
///
|
pub fn start_app<COMP>()
|
||||||
/// The purpose of this module is to alleviate imports of many common types:
|
where
|
||||||
///
|
COMP: Component + Renderable<COMP>,
|
||||||
/// ```
|
{
|
||||||
/// # #![allow(unused_imports)]
|
initialize();
|
||||||
/// use yew::prelude::*;
|
App::<COMP>::new().mount_to_body();
|
||||||
/// ```
|
run_loop();
|
||||||
pub mod prelude {
|
|
||||||
pub use html::{
|
|
||||||
Component,
|
|
||||||
ComponentLink,
|
|
||||||
Href,
|
|
||||||
Html,
|
|
||||||
Renderable,
|
|
||||||
ShouldRender,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub use app::App;
|
|
||||||
|
|
||||||
pub use callback::Callback;
|
|
||||||
|
|
||||||
pub use agent::{
|
|
||||||
Bridge,
|
|
||||||
Bridged,
|
|
||||||
Threaded,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub use events::*;
|
|
||||||
|
|
||||||
/// Prelude module for creating worker.
|
|
||||||
pub mod worker {
|
|
||||||
pub use agent::{
|
|
||||||
Agent,
|
|
||||||
AgentLink,
|
|
||||||
Bridge,
|
|
||||||
Bridged,
|
|
||||||
Context,
|
|
||||||
Global,
|
|
||||||
HandlerId,
|
|
||||||
Job,
|
|
||||||
Private,
|
|
||||||
Public,
|
|
||||||
Transferable,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub use self::prelude::*;
|
|
||||||
|
|
||||||
/// The module that contains all events available in the framework.
|
/// The module that contains all events available in the framework.
|
||||||
pub mod events {
|
pub mod events {
|
||||||
pub use html::{
|
pub use html::{
|
||||||
@ -203,3 +163,53 @@ pub mod events {
|
|||||||
SubmitEvent
|
SubmitEvent
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The Yew Prelude
|
||||||
|
///
|
||||||
|
/// The purpose of this module is to alleviate imports of many common types:
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// # #![allow(unused_imports)]
|
||||||
|
/// use yew::prelude::*;
|
||||||
|
/// ```
|
||||||
|
pub mod prelude {
|
||||||
|
pub use html::{
|
||||||
|
Component,
|
||||||
|
ComponentLink,
|
||||||
|
Href,
|
||||||
|
Html,
|
||||||
|
Renderable,
|
||||||
|
ShouldRender,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub use app::App;
|
||||||
|
|
||||||
|
pub use callback::Callback;
|
||||||
|
|
||||||
|
pub use agent::{
|
||||||
|
Bridge,
|
||||||
|
Bridged,
|
||||||
|
Threaded,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub use events::*;
|
||||||
|
|
||||||
|
/// Prelude module for creating worker.
|
||||||
|
pub mod worker {
|
||||||
|
pub use agent::{
|
||||||
|
Agent,
|
||||||
|
AgentLink,
|
||||||
|
Bridge,
|
||||||
|
Bridged,
|
||||||
|
Context,
|
||||||
|
Global,
|
||||||
|
HandlerId,
|
||||||
|
Job,
|
||||||
|
Private,
|
||||||
|
Public,
|
||||||
|
Transferable,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub use self::prelude::*;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user