This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load up the RecipeViewModels stored in our index. | |
var recipeViewModel = ravenSession.Query<RecipeViewModel, RecipeViewModelIndex>() | |
.Where(r => r.Name == "Sweet honey glazed salmon") | |
.ProjectFromIndexFieldsInto<RecipeViewModel>() | |
.First(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'"> | |
<TypeScriptTarget>ES5</TypeScriptTarget> | |
<TypeScriptJSXEmit>None</TypeScriptJSXEmit> | |
<TypeScriptCompileOnSaveEnabled>True</TypeScriptCompileOnSaveEnabled> | |
<TypeScriptNoImplicitAny>False</TypeScriptNoImplicitAny> | |
<TypeScriptModuleKind>None</TypeScriptModuleKind> | |
<TypeScriptRemoveComments>False</TypeScriptRemoveComments> | |
<TypeScriptOutFile /> | |
<TypeScriptOutDir /> | |
<TypeScriptGeneratesDeclarations>False</TypeScriptGeneratesDeclarations> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Old, sucky way of doing async work: callback hell! | |
function myCallback(result) { | |
this.items = result; | |
} | |
someAjaxRequest(myCallback); | |
// 2. Slightly better way using Promises! | |
someAjaxRequest().then(results => this.items = results); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"noImplicitAny": false, | |
"noEmitOnError": true, | |
"removeComments": false, | |
"sourceMap": false, | |
"target": "es5", | |
"strictNullChecks": true, | |
}, | |
"compileOnSave": true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.run([ | |
"$q", | |
function ($q: ng.IQService) { | |
// Use Angular's Q object as Promise. This is needed to make async/await work properly with the UI. | |
// See http://stackoverflow.com/a/41825004/536 | |
window["Promise"] = $q; | |
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UsersController { | |
users: User[] = []; | |
constructor() { | |
this.fetchUsers(); | |
} | |
async fetchUsers() { | |
var result = await this.$http.get("/users/all"); // Put this in a service, obviously. userService.get() or whatever. | |
this.users = result; // Yay! The UI will automatically update to show these users. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | |
return new (P || (P = Promise))(function (resolve, reject) { | |
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | |
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | |
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | |
step((generator = generator.apply(thisArg, _arguments || [])).next()); | |
}); | |
}; | |
var __generator = (this && this.__generator) || function (thisArg, body) { | |
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"compilerOptions": { | |
"noImplicitAny": false, | |
"noEmitOnError": true, | |
"removeComments": false, | |
"sourceMap": false, | |
"target": "es5", | |
"noEmitHelpers": true, | |
"strictNullChecks": true | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UsersController.prototype.fetchUsers = function () { | |
return __awaiter(this, void 0, void 0, function () { | |
var results; | |
return __generator(this, function (_a) { | |
switch (_a.label) { | |
case 0: return [4 /*yield*/, this.usersApi.getUsers(0, 100)]; | |
case 1: | |
results = _a.sent(); | |
this.users = results; | |
return [2 /*return*/]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ConfigureServices(IServiceCollection services) | |
{ | |
// Add RavenDB and identity. | |
services | |
.AddRavenDb(Configuration.GetConnectionString("RavenDbConnection")) // Create a RavenDB DocumentStore singleton. | |
.AddRavenDbAsyncSession() // Create a RavenDB IAsyncDocumentSession for each request. | |
.AddRavenDbIdentity<AppUser>(); // Use Raven for users and roles. AppUser is your class, a simple DTO to hold user data. See https://github.com/JudahGabriel/RavenDB.Identity/blob/master/Sample/Models/AppUser.cs | |
... | |
} |