Adjust APIs for simpler examples in blog post
This commit is contained in:
parent
933fb87013
commit
1d3ca8eb5d
4 changed files with 13 additions and 8 deletions
|
@ -111,14 +111,20 @@ pub struct App(Rc<AppCell>);
|
||||||
/// configured, you'll start the app with `App::run`.
|
/// configured, you'll start the app with `App::run`.
|
||||||
impl App {
|
impl App {
|
||||||
/// Builds an app with the given asset source.
|
/// Builds an app with the given asset source.
|
||||||
pub fn production(asset_source: Arc<dyn AssetSource>) -> Self {
|
pub fn new() -> Self {
|
||||||
Self(AppContext::new(
|
Self(AppContext::new(
|
||||||
current_platform(),
|
current_platform(),
|
||||||
asset_source,
|
Arc::new(()),
|
||||||
http::client(),
|
http::client(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Assign
|
||||||
|
pub fn with_assets(self, asset_source: impl AssetSource) -> Self {
|
||||||
|
self.0.borrow_mut().asset_source = Arc::new(asset_source);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Start the application. The provided callback will be called once the
|
/// Start the application. The provided callback will be called once the
|
||||||
/// app is fully launched.
|
/// app is fully launched.
|
||||||
pub fn run<F>(self, on_finish_launching: F)
|
pub fn run<F>(self, on_finish_launching: F)
|
||||||
|
@ -1167,7 +1173,7 @@ impl Context for AppContext {
|
||||||
type Result<T> = T;
|
type Result<T> = T;
|
||||||
|
|
||||||
/// Build an entity that is owned by the application. The given function will be invoked with
|
/// Build an entity that is owned by the application. The given function will be invoked with
|
||||||
/// a `ModelContext` and must return an object representing the entity. A `Model` will be returned
|
/// a `ModelContext` and must return an object representing the entity. A `Model` handle will be returned,
|
||||||
/// which can be used to access the entity in a context.
|
/// which can be used to access the entity in a context.
|
||||||
fn new_model<T: 'static>(
|
fn new_model<T: 'static>(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{sync::Arc, time::Duration};
|
use std::time::Duration;
|
||||||
|
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use gpui::{actions, KeyBinding, Menu, MenuItem};
|
use gpui::{actions, KeyBinding, Menu, MenuItem};
|
||||||
|
@ -12,7 +12,7 @@ actions!(live_kit_client, [Quit]);
|
||||||
fn main() {
|
fn main() {
|
||||||
SimpleLogger::init(LevelFilter::Info, Default::default()).expect("could not initialize logger");
|
SimpleLogger::init(LevelFilter::Info, Default::default()).expect("could not initialize logger");
|
||||||
|
|
||||||
gpui::App::production(Arc::new(())).run(|cx| {
|
gpui::App::new().run(|cx| {
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
println!("USING TEST LIVEKIT");
|
println!("USING TEST LIVEKIT");
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,7 @@ fn main() {
|
||||||
});
|
});
|
||||||
let theme_name = args.theme.unwrap_or("One Dark".to_string());
|
let theme_name = args.theme.unwrap_or("One Dark".to_string());
|
||||||
|
|
||||||
let asset_source = Arc::new(Assets);
|
gpui::App::new().with_assets(Assets).run(move |cx| {
|
||||||
gpui::App::production(asset_source).run(move |cx| {
|
|
||||||
load_embedded_fonts(cx).unwrap();
|
load_embedded_fonts(cx).unwrap();
|
||||||
|
|
||||||
let mut store = SettingsStore::default();
|
let mut store = SettingsStore::default();
|
||||||
|
|
|
@ -67,7 +67,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!("========== starting zed ==========");
|
log::info!("========== starting zed ==========");
|
||||||
let app = App::production(Arc::new(Assets));
|
let app = App::new().with_assets(Assets);
|
||||||
|
|
||||||
let (installation_id, existing_installation_id_found) = app
|
let (installation_id, existing_installation_id_found) = app
|
||||||
.background_executor()
|
.background_executor()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue