Skip to content

Instantly share code, notes, and snippets.

@SteveSanderson
SteveSanderson / StringInterpolatingBindingProvider.js
Created July 8, 2013 11:16
String-interpolating binding provider example for KO 3.0.0 beta. Allows {{ expr }} expressions to insert text into the DOM.
/* --- String interpolating binding provider ---
Allows {{ expr }} syntax in DOM. Could be an official KO plugin
loaded from a separate file. Note that preprocessNode is a fairly
low-level API that developers are not often expected to use directly.
*/
var StringInterpolatingBindingProvider = function() {
this.constructor = StringInterpolatingBindingProvider;
var expressionRegex = /{{([\s\S]+?)}}/g;
/*! Knockout projections plugin - version 1.1.0-pre
------------------------------------------------------------------------------
Copyright (c) Microsoft Corporation
All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions and limitations under the License.
------------------------------------------------------------------------------
*/
@SteveSanderson
SteveSanderson / somefile.cs
Last active May 11, 2016 23:56
Async void message loop
public class MyNetworkClient {
public async Task ConnectAsync(string address) {
await this.MakeTheActualConnection(address);
this.BeginReceiveLoop();
}
// It's async void! But is that bad?
// I know that an unhandled exception here is going to bring down the process, but where else do you want
// that exception to go? There's no external control flow that can reasonably receive such an exception.
private async void BeginReceiveLoop() {